From: Richard Henderson Date: Tue, 10 Apr 2001 16:49:29 +0000 (-0700) Subject: typeck.c (build_array_ref): Push the array reference inside COMPOUND_EXPR and COND_EXPR. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0450d74d53b419f6455d9fc4f12ccf2a37ce61b8;p=gcc.git typeck.c (build_array_ref): Push the array reference inside COMPOUND_EXPR and COND_EXPR. * typeck.c (build_array_ref): Push the array reference inside COMPOUND_EXPR and COND_EXPR. From-SVN: r41223 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2f3c032dd28..1b0c470aba7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2001-04-10 Richard Henderson + + * typeck.c (build_array_ref): Push the array reference inside + COMPOUND_EXPR and COND_EXPR. + 2001-04-05 Mark Mitchell * cp-tree.h (DECL_THIS_INLINE): Rename to DECL_DECLARED_INLINE_P. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 673e7c34554..139290bb166 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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