diff options
author | Richard Stallman <rms@gnu.org> | 1992-06-26 12:54:41 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1992-06-26 12:54:41 +0000 |
commit | 5a7ec9d91acb245ce5b46a002201f7a2ead8b940 (patch) | |
tree | 1a021c9654f777923b021aa8ebd1e4a9d6e6ecfb | |
parent | 536bb15b8f5fdd59241bdf2eac29298aa61fb272 (diff) | |
download | gcc-5a7ec9d91acb245ce5b46a002201f7a2ead8b940.zip gcc-5a7ec9d91acb245ce5b46a002201f7a2ead8b940.tar.gz gcc-5a7ec9d91acb245ce5b46a002201f7a2ead8b940.tar.bz2 |
(process_init_constructor): Strip NON_LVALUE_EXPR
from specified array index.
From-SVN: r1300
-rw-r--r-- | gcc/c-typeck.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 12505e7..bca1eb1 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4864,17 +4864,20 @@ process_init_constructor (type, init, elts, constant_value, constant_element, if (TREE_PURPOSE (tail) != 0) { int win = 0; + tree index = TREE_PURPOSE (tail); - if (TREE_CODE (TREE_PURPOSE (tail)) == IDENTIFIER_NODE) + if (index && TREE_CODE (index) == NON_LVALUE_EXPR) + index = TREE_OPERAND (index, 0); + + if (TREE_CODE (index) == IDENTIFIER_NODE) error ("field name used as index in array initializer"); - else if (TREE_CODE (TREE_PURPOSE (tail)) != INTEGER_CST) + else if (TREE_CODE (index) != INTEGER_CST) error ("non-constant array index in initializer"); - else if (tree_int_cst_lt (TREE_PURPOSE (tail), min_index) - || (max_index && tree_int_cst_lt (max_index, - TREE_PURPOSE (tail)))) + else if (tree_int_cst_lt (index, min_index) + || (max_index && tree_int_cst_lt (max_index, index))) error ("array index out of range in initializer"); else - current_index = TREE_PURPOSE (tail), win = 1; + current_index = index, win = 1; if (!win) TREE_VALUE (tail) = error_mark_node; |