summaryrefslogtreecommitdiff
path: root/gcc/cp/cp-gimplify.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-05 19:02:46 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-05 19:02:46 +0000
commit94deb769dd50c1ba86e1139eea7fc0bd075ed4d6 (patch)
tree8df473c5a1f98acadecb2f68d4e7a78d4014022c /gcc/cp/cp-gimplify.c
parent84f7af3e396421fb995bb4a848f02e2ef63a1b15 (diff)
downloadgcc-94deb769dd50c1ba86e1139eea7fc0bd075ed4d6.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166372 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/cp-gimplify.c')
-rw-r--r--gcc/cp/cp-gimplify.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index dd879c63b15..705979d6c55 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);