diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-11-05 20:02:46 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2010-11-05 20:02:46 +0100 |
commit | 897145e3e11c868abb2b5ec23ef5f65a87914270 (patch) | |
tree | 8df473c5a1f98acadecb2f68d4e7a78d4014022c /gcc | |
parent | ee01a467d1b18dfe0f3b8eedb7fa3507310294ed (diff) | |
download | gcc-897145e3e11c868abb2b5ec23ef5f65a87914270.zip gcc-897145e3e11c868abb2b5ec23ef5f65a87914270.tar.gz gcc-897145e3e11c868abb2b5ec23ef5f65a87914270.tar.bz2 |
re PR c++/46160 (ICE with volatile structure and enum)
PR c++/46160
* cp-gimplify.c (cp_gimplify_expr): Drop volatile MEM_REFs
on the RHS to avoid infinite recursion with gimplify_expr.
* g++.dg/opt/empty2.C: New test.
From-SVN: r166372
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/empty2.C | 18 |
4 files changed, 37 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e884898..939b05a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-11-05 Jakub Jelinek <jakub@redhat.com> + + PR c++/46160 + * cp-gimplify.c (cp_gimplify_expr): Drop volatile MEM_REFs + on the RHS to avoid infinite recursion with gimplify_expr. + 2010-11-05 Jason Merrill <jason@redhat.com> PR c++/46304 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index dd879c6..705979d 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -595,6 +595,16 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) if (!TREE_SIDE_EFFECTS (op1) || (DECL_P (op1) && TREE_THIS_VOLATILE (op1))) *expr_p = op0; + else if (TREE_CODE (op1) == MEM_REF + && TREE_THIS_VOLATILE (op1)) + { + /* Similarly for volatile MEM_REFs on the RHS. */ + if (!TREE_SIDE_EFFECTS (TREE_OPERAND (op1, 0))) + *expr_p = op0; + else + *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p), + TREE_OPERAND (op1, 0), op0); + } else *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p), op0, op1); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index debdd54..203f3e0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-11-05 Jakub Jelinek <jakub@redhat.com> + PR c++/46160 + * g++.dg/opt/empty2.C: New test. + PR target/45670 * gcc.target/i386/pr45670.c: New test. diff --git a/gcc/testsuite/g++.dg/opt/empty2.C b/gcc/testsuite/g++.dg/opt/empty2.C new file mode 100644 index 0000000..86caa5c --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/empty2.C @@ -0,0 +1,18 @@ +// PR c++/46160 +// { dg-do compile } + +struct S +{ + enum E { A }; +} s; +volatile S t; + +void f (S::E); + +void +g () +{ + volatile S *p = &s; + f (p->A); + f (t.A); +} |