diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-24 17:24:32 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-24 17:24:32 +0000 |
commit | 88c32270aa798c7e60d83f97eb456a440c7db5db (patch) | |
tree | a6300e7d88299fc54fd9ad19a6c84f9e22ccfa43 /gcc/c-typeck.c | |
parent | 5daf45f29a68366981a30dc0deb3dae9b494d5ba (diff) | |
download | ppe42-gcc-88c32270aa798c7e60d83f97eb456a440c7db5db.tar.gz ppe42-gcc-88c32270aa798c7e60d83f97eb456a440c7db5db.zip |
* c-typeck.c (set_init_index): Allow array designators that are
not integer constant expressions with a pedwarn if pedantic.
testsuite:
* gcc.dg/array-const-1.c, gcc.dg/array-const-2.c,
gcc.dg/array-const-3.c: New tests.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146741 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c7ea3284ac0..1cfab1f14f2 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -6422,6 +6422,24 @@ set_init_index (tree first, tree last) } if (TREE_CODE (first) != INTEGER_CST) + { + first = c_fully_fold (first, false, NULL); + if (TREE_CODE (first) == INTEGER_CST) + pedwarn_init (input_location, OPT_pedantic, + "array index in initializer is not " + "an integer constant expression"); + } + + if (last && TREE_CODE (last) != INTEGER_CST) + { + last = c_fully_fold (last, false, NULL); + if (TREE_CODE (last) == INTEGER_CST) + pedwarn_init (input_location, OPT_pedantic, + "array index in initializer is not " + "an integer constant expression"); + } + + if (TREE_CODE (first) != INTEGER_CST) error_init ("nonconstant array index in initializer"); else if (last != 0 && TREE_CODE (last) != INTEGER_CST) error_init ("nonconstant array index in initializer"); |