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 6af8d2fd14ec8ee9b8009aba3262a1307786e1cb..e6fb95b3c785bfee9bfc8757168eaa824a7018ea 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 5880171b336071c100c3988682fb9a8a8042fa70..da617c7e01bc7fa00043f2994e8af088271ebd47 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 63a29f4868c4c3f051af9d2ea3bf37e21158873f..1e1a1be1f20d2245fcc0adaa0d332a2e296c0229 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: