re PR c++/56419 (transactions in for-loops disappear)
authorAldy Hernandez <aldyh@redhat.com>
Tue, 26 Feb 2013 12:40:27 +0000 (12:40 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Tue, 26 Feb 2013 12:40:27 +0000 (12:40 +0000)
PR c++/56419
* semantics.c (begin_transaction_stmt): Set TREE_SIDE_EFFECTS.
(build_transaction_expr): Same.

From-SVN: r196282

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/tm/pr56419.C [new file with mode: 0644]

index c2a2b3c223a695db254de05d211f28dc833a2e88..7ab31f3e8ad694c921de5e817dc8f08ad20b5a01 100644 (file)
@@ -1,3 +1,9 @@
+2013-02-25  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR c++/56419
+       * semantics.c (begin_transaction_stmt): Set TREE_SIDE_EFFECTS.
+       (build_transaction_expr): Same.
+
 2013-02-25  Jason Merrill  <jason@redhat.com>
 
        PR c++/56377
index 60271b511ad03b04f16e6ce509f5d222dba3900c..9446f831bd5fac0dfc1c1bed76983a144a77b7e6 100644 (file)
@@ -5108,6 +5108,7 @@ begin_transaction_stmt (location_t loc, tree *pcompound, int flags)
                         "transactional memory support enabled")));
 
   TRANSACTION_EXPR_BODY (r) = push_stmt_list ();
+  TREE_SIDE_EFFECTS (r) = 1;
   return r;
 }
 
@@ -5157,6 +5158,7 @@ build_transaction_expr (location_t loc, tree expr, int flags, tree noex)
   ret = build1 (TRANSACTION_EXPR, TREE_TYPE (expr), expr);
   if (flags & TM_STMT_ATTR_RELAXED)
        TRANSACTION_EXPR_RELAXED (ret) = 1;
+  TREE_SIDE_EFFECTS (ret) = 1;
   SET_EXPR_LOCATION (ret, loc);
   return ret;
 }
diff --git a/gcc/testsuite/g++.dg/tm/pr56419.C b/gcc/testsuite/g++.dg/tm/pr56419.C
new file mode 100644 (file)
index 0000000..c9a33a8
--- /dev/null
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm" }
+
+int x = 0;
+int inc_func(int i) {
+     for (int j = 0; j < i; ++j)
+     {
+         __transaction_atomic { x+=1; }
+     }
+     return 0;
+}
+
+// { dg-final { scan-assembler "ITM_commitTransaction" } }