re PR c++/84704 (internal compiler error: gimplification failed)
authorJakub Jelinek <jakub@redhat.com>
Mon, 12 Mar 2018 23:39:21 +0000 (00:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 12 Mar 2018 23:39:21 +0000 (00:39 +0100)
PR c++/84704
* tree.c (stabilize_reference_1): Return save_expr (e) for
STATEMENT_LIST even if it doesn't have side-effects.

* g++.dg/debug/pr84704.C: New test.

From-SVN: r258470

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/pr84704.C [new file with mode: 0644]
gcc/tree.c

index 6af8d2f..e6fb95b 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84704
+       * tree.c (stabilize_reference_1): Return save_expr (e) for
+       STATEMENT_LIST even if it doesn't have side-effects.
+
 2018-03-12  Jonathan Wakely  <jwakely@redhat.com>
 
        * doc/invoke.texi (-mclflushopt): Fix spelling of option.
index 5880171..da617c7 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84704
+       * g++.dg/debug/pr84704.C: New test.
+
 2018-03-12  Renlin Li  <renlin.li@arm.com>
 
        * gcc.target/aarch64/movi_hf.c: New.
diff --git a/gcc/testsuite/g++.dg/debug/pr84704.C b/gcc/testsuite/g++.dg/debug/pr84704.C
new file mode 100644 (file)
index 0000000..3043edb
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/84704
+// { dg-do compile }
+// { dg-options "-g -fcompare-debug -O2" }
+
+int a[1] = { 0 };
+
+void
+foo ()
+{
+  a[({ 0; })] %= 5;
+}
index 63a29f4..1e1a1be 100644 (file)
@@ -4352,6 +4352,11 @@ stabilize_reference_1 (tree e)
   switch (TREE_CODE_CLASS (code))
     {
     case tcc_exceptional:
+      /* Always wrap STATEMENT_LIST into SAVE_EXPR, even if it doesn't
+        have side-effects.  */
+      if (code == STATEMENT_LIST)
+       return save_expr (e);
+      /* FALLTHRU */
     case tcc_type:
     case tcc_declaration:
     case tcc_comparison: