From: kraai Date: Tue, 19 Aug 2003 01:36:29 +0000 (+0000) Subject: PR c/11207 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42b1a257e632e9cff988c72f8d04cf966db3c457;p=thirdparty%2Fgcc.git PR c/11207 * c-typeck.c (set_init_index): Check for negative index. (testsuite/) * gcc.dg/noncompile/20030818-1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70553 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d14e72c935af..b62d2c98a2ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2003-08-18 Matt Kraai + + PR c/11207 + * c-typeck.c (set_init_index): Check for negative index. + 2003-08-18 Bob Wilson * config/xtensa/crti.asm (_init, _fini): Add alternate code for new diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 224741bf819b..423d6bdca12c 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 6a38f18f506c..29553cd3603f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-08-18 Matt Kraai + + * gcc.dg/noncompile/20030818-1.c: New. + 2003-08-18 Nathan Sidwell * 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 000000000000..6e626290329c --- /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" } */