Commit d7d93837 by Aldy Hernandez Committed by Aldy Hernandez

re PR c++/24138 (ICE with the code in PR 20407)

        PR C++/24138
        * tree.c (integer_all_onesp): Always return true if all bits on.

        * cp/decl.c (reshape_init_array_1): Handle max_index of -1.

        * testsuite/g++.dg/init/array0.C: New.

From-SVN: r108126
parent 3af22b23
2005-12-06 Aldy Hernandez <aldyh@redhat.com>
PR C++/24138
* tree.c (integer_all_onesp): Always return true if all bits on.
* testsuite/g++.dg/init/array0.C: New.
2005-12-06 Adrian Straetling <straetling@de.ibm.com> 2005-12-06 Adrian Straetling <straetling@de.ibm.com>
* doc/md.texi: Adapt to implementation. * doc/md.texi: Adapt to implementation.
......
2005-12-06 Aldy Hernandez <aldyh@redhat.com>
PR C++/24138
* decl.c (reshape_init_array_1): Handle max_index of -1.
2005-12-06 Roger Sayle <roger@eyesopen.com> 2005-12-06 Roger Sayle <roger@eyesopen.com>
* typeck.c (build_binary_op): Issue warning if either operand of a * typeck.c (build_binary_op): Issue warning if either operand of a
......
...@@ -4209,6 +4209,10 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d) ...@@ -4209,6 +4209,10 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d)
if (sized_array_p) if (sized_array_p)
{ {
/* Minus 1 is used for zero sized arrays. */
if (integer_all_onesp (max_index))
return new_init;
if (host_integerp (max_index, 1)) if (host_integerp (max_index, 1))
max_index_cst = tree_low_cst (max_index, 1); max_index_cst = tree_low_cst (max_index, 1);
/* sizetype is sign extended, not zero extended. */ /* sizetype is sign extended, not zero extended. */
......
// { dg-do compile }
// { dg-options "" }
// PR C++/24138
void foo()
{
typedef struct {
unsigned char dir;
int data[0];
} yanito;
static const yanito horse = { 1, { 2, 3 } }; // { dg-error "too many" }
}
...@@ -1208,9 +1208,11 @@ integer_all_onesp (tree expr) ...@@ -1208,9 +1208,11 @@ integer_all_onesp (tree expr)
return 0; return 0;
uns = TYPE_UNSIGNED (TREE_TYPE (expr)); uns = TYPE_UNSIGNED (TREE_TYPE (expr));
if (TREE_INT_CST_LOW (expr) == ~(unsigned HOST_WIDE_INT) 0
&& TREE_INT_CST_HIGH (expr) == -1)
return 1;
if (!uns) if (!uns)
return (TREE_INT_CST_LOW (expr) == ~(unsigned HOST_WIDE_INT) 0 return 0;
&& TREE_INT_CST_HIGH (expr) == -1);
/* Note that using TYPE_PRECISION here is wrong. We care about the /* Note that using TYPE_PRECISION here is wrong. We care about the
actual bits, not the (arbitrary) range of the type. */ actual bits, not the (arbitrary) range of the type. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment