aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMatt Kraai <kraai@alumni.cmu.edu>2003-08-19 01:36:29 +0000
committerMatt Kraai <kraai@gcc.gnu.org>2003-08-19 01:36:29 +0000
commit622adc7e1d0dd764163518b15256f3ac381e407f (patch)
tree50a577fb9ed3e7bcd37c9eda48702887e18167ec /gcc
parentdfccfad9bba8dbc71157e1ece97e785e895b9799 (diff)
downloadgcc-622adc7e1d0dd764163518b15256f3ac381e407f.zip
gcc-622adc7e1d0dd764163518b15256f3ac381e407f.tar.gz
gcc-622adc7e1d0dd764163518b15256f3ac381e407f.tar.bz2
re PR c/11207 (ICE with negative index in array element designator)
PR c/11207 * c-typeck.c (set_init_index): Check for negative index. (testsuite/) * gcc.dg/noncompile/20030818-1.c: New. From-SVN: r70553
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/20030818-1.c3
4 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d14e72c..b62d2c9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-08-18 Matt Kraai <kraai@alumni.cmu.edu>
+
+ PR c/11207
+ * c-typeck.c (set_init_index): Check for negative index.
+
2003-08-18 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/crti.asm (_init, _fini): Add alternate code for new
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 224741b..423d6bd 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4956,6 +4956,8 @@ set_init_index (tree first, tree last)
error_init ("nonconstant array index in initializer");
else if (TREE_CODE (constructor_type) != ARRAY_TYPE)
error_init ("array index in non-array initializer");
+ else if (tree_int_cst_sgn (first) == -1)
+ error_init ("array index in initializer exceeds array bounds");
else if (constructor_max_index
&& tree_int_cst_lt (constructor_max_index, first))
error_init ("array index in initializer exceeds array bounds");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6a38f18..29553cd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-08-18 Matt Kraai <kraai@alumni.cmu.edu>
+
+ * gcc.dg/noncompile/20030818-1.c: New.
+
2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/template/scope2.C: New test.
diff --git a/gcc/testsuite/gcc.dg/noncompile/20030818-1.c b/gcc/testsuite/gcc.dg/noncompile/20030818-1.c
new file mode 100644
index 0000000..6e62629
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/20030818-1.c
@@ -0,0 +1,3 @@
+/* PR 11207. */
+
+char font8x8[256][8] = { [-1] = { 0 } }; /* { dg-error "array index in initializer exceeds array bounds" } */