From: Mark Mitchell Date: Sun, 1 Jul 2001 20:50:03 +0000 (+0000) Subject: expr.c (expand_expr, [...]): Correct check for side-effects in the value of an array... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c54b0a5e4b261487b58d4ec2db7219f8f5c7233d;p=gcc.git expr.c (expand_expr, [...]): Correct check for side-effects in the value of an array element. * expr.c (expand_expr, case ARRAY_REF): Correct check for side-effects in the value of an array element. From-SVN: r43680 --- diff --git a/gcc/expr.c b/gcc/expr.c index c5276f2556e..afa55a68708 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6902,7 +6902,7 @@ expand_expr (exp, target, tmode, modifier) elem = TREE_CHAIN (elem)) ; - if (elem && !TREE_SIDE_EFFECTS (elem)) + if (elem && !TREE_SIDE_EFFECTS (TREE_VALUE (elem))) return expand_expr (fold (TREE_VALUE (elem)), target, tmode, ro_modifier); } diff --git a/gcc/testsuite/g++.old-deja/g++.other/array6.C b/gcc/testsuite/g++.old-deja/g++.other/array6.C new file mode 100644 index 00000000000..ab076f2af38 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/array6.C @@ -0,0 +1,20 @@ +// Special g++ Options: -O1 + +int count = 0; + +double foo () { + count++; + return 0; +}; + +double bar () { + const double x[1] = { foo() }; + return x[0]; +}; + +int main () +{ + bar(); + if (count != 1) + return 1; +};