From: Richard Stallman Date: Fri, 26 Jun 1992 12:54:41 +0000 (+0000) Subject: (process_init_constructor): Strip NON_LVALUE_EXPR X-Git-Tag: misc/cutover-egcs-0~12631 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a7ec9d91acb245ce5b46a002201f7a2ead8b940;p=thirdparty%2Fgcc.git (process_init_constructor): Strip NON_LVALUE_EXPR from specified array index. From-SVN: r1300 --- diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 12505e76c89c..bca1eb1aa31f 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;