summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/expr.c2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/array6.C20
2 files changed, 21 insertions, 1 deletions
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;
+};
OpenPOWER on IntegriCloud