OSDN Git Service

* typeck.c (build_array_ref): Push the array reference inside
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Apr 2001 16:49:29 +0000 (16:49 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Apr 2001 16:49:29 +0000 (16:49 +0000)
        COMPOUND_EXPR and COND_EXPR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@41223 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck.c

index 2f3c032..1b0c470 100644 (file)
@@ -1,3 +1,8 @@
+2001-04-10  Richard Henderson  <rth@redhat.com>
+
+       * typeck.c (build_array_ref): Push the array reference inside
+       COMPOUND_EXPR and COND_EXPR.
+
 2001-04-05  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (DECL_THIS_INLINE): Rename to DECL_DECLARED_INLINE_P.
index 673e7c3..139290b 100644 (file)
@@ -2433,6 +2433,27 @@ build_array_ref (array, idx)
       || TREE_TYPE (idx) == error_mark_node)
     return error_mark_node;
 
+  /* If ARRAY is a COMPOUND_EXPR or COND_EXPR, move our reference
+     inside it.  */
+  switch (TREE_CODE (array))
+    {
+    case COMPOUND_EXPR:
+      {
+       tree value = build_array_ref (TREE_OPERAND (array, 1), idx);
+       return build (COMPOUND_EXPR, TREE_TYPE (value),
+                     TREE_OPERAND (array, 0), value);
+      }
+
+    case COND_EXPR:
+      return build_conditional_expr
+       (TREE_OPERAND (array, 0),
+        build_array_ref (TREE_OPERAND (array, 1), idx),
+        build_array_ref (TREE_OPERAND (array, 2), idx));
+
+    default:
+      break;
+    }
+
   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE
       && TREE_CODE (array) != INDIRECT_REF)
     {
@@ -2469,6 +2490,7 @@ build_array_ref (array, idx)
          if (mark_addressable (array) == 0)
            return error_mark_node;
        }
+
       /* An array that is indexed by a constant value which is not within
         the array bounds cannot be stored in a register either; because we
         would get a crash in store_bit_field/extract_bit_field when trying