From 038df1baecf93ad9d17ba7deafb47e99b3e287ad Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 13 Mar 2018 00:39:21 +0100 Subject: [PATCH] re PR c++/84704 (internal compiler error: gimplification failed) 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 | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/debug/pr84704.C | 11 +++++++++++ gcc/tree.c | 5 +++++ 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/pr84704.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6af8d2fd14e..e6fb95b3c78 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-13 Jakub Jelinek + + 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 * doc/invoke.texi (-mclflushopt): Fix spelling of option. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5880171b336..da617c7e01b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-13 Jakub Jelinek + + PR c++/84704 + * g++.dg/debug/pr84704.C: New test. + 2018-03-12 Renlin Li * 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 index 00000000000..3043edb6460 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr84704.C @@ -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; +} diff --git a/gcc/tree.c b/gcc/tree.c index 63a29f4868c..1e1a1be1f20 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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: -- 2.30.2