]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
(process_init_constructor): Strip NON_LVALUE_EXPR
authorRichard Stallman <rms@gnu.org>
Fri, 26 Jun 1992 12:54:41 +0000 (12:54 +0000)
committerRichard Stallman <rms@gnu.org>
Fri, 26 Jun 1992 12:54:41 +0000 (12:54 +0000)
from specified array index.

From-SVN: r1300

gcc/c-typeck.c

index 12505e76c89c3428a7766f0a6652ffdb2da9e75e..bca1eb1aa31facd334feeb02c5726ebe524c45cc 100644 (file)
@@ -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;