re PR c++/56419 (transactions in for-loops disappear)

PR c++/56419
	* semantics.c (begin_transaction_stmt): Set TREE_SIDE_EFFECTS.
	(build_transaction_expr): Same.

From-SVN: r196282
This commit is contained in:
Aldy Hernandez 2013-02-26 12:40:27 +00:00 committed by Aldy Hernandez
parent f1ad33546d
commit 6f2d959b9e
3 changed files with 21 additions and 0 deletions

View 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

View 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;
}

View File

@ -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" } }