aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2005-12-06 19:45:00 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2005-12-06 19:45:00 +0000
commitd7d938374664ca711b5bb894486394425d8c9227 (patch)
tree9a4d882c3bd13e5816af7f4580ea174e21a1509f /gcc
parent3af22b23b32d69bd7cc0d444429f33e4edae008d (diff)
downloadgcc-d7d938374664ca711b5bb894486394425d8c9227.zip
gcc-d7d938374664ca711b5bb894486394425d8c9227.tar.gz
gcc-d7d938374664ca711b5bb894486394425d8c9227.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/testsuite/g++.dg/init/array0.C12
-rw-r--r--gcc/tree.c6
5 files changed, 32 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f65ed23..ea51aa2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+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>
* doc/md.texi: Adapt to implementation.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d133d8b..77f506e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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>
* typeck.c (build_binary_op): Issue warning if either operand of a
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b5f89fc..ffa5e33 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4209,6 +4209,10 @@ reshape_init_array_1 (tree elt_type, tree max_index, reshape_iter *d)
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))
max_index_cst = tree_low_cst (max_index, 1);
/* sizetype is sign extended, not zero extended. */
diff --git a/gcc/testsuite/g++.dg/init/array0.C b/gcc/testsuite/g++.dg/init/array0.C
new file mode 100644
index 0000000..235cdf0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array0.C
@@ -0,0 +1,12 @@
+// { 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" }
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index 324e833..42da689 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1208,9 +1208,11 @@ integer_all_onesp (tree expr)
return 0;
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)
- return (TREE_INT_CST_LOW (expr) == ~(unsigned HOST_WIDE_INT) 0
- && TREE_INT_CST_HIGH (expr) == -1);
+ return 0;
/* Note that using TYPE_PRECISION here is wrong. We care about the
actual bits, not the (arbitrary) range of the type. */