From: Jakub Jelinek Date: Mon, 12 Mar 2018 23:39:21 +0000 (+0100) Subject: re PR c++/84704 (internal compiler error: gimplification failed) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=038df1baecf93ad9d17ba7deafb47e99b3e287ad;p=gcc.git 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 --- 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: