| Submitter | Torvald Riegel |
|---|---|
| Date | Nov. 21, 2011, 8:25 p.m. |
| Message ID | <1321907100.12248.123.camel@triegel.csb> |
| Download | mbox | patch |
| Permalink | /patch/126917/ |
| State | New |
| Headers | show |
Comments
On 11/21/2011 12:25 PM, Torvald Riegel wrote: > gcc/cp/ > * pt.c (tsubst_copy_and_build): Handle TRANSACTION_EXPR. Ok. > +/* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 2 "tmmark" } } */ This needs to cater to sizeof(int) != 4. Why not just match "ITM_RU" and leave it at that? r~
Patch
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2ba26b2..f817b6f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14290,6 +14290,10 @@ tsubst_copy_and_build (tree t, return r; } + case TRANSACTION_EXPR: + return tsubst_expr(t, args, complain, in_decl, + integral_constant_expression_p); + default: /* Handle Objective-C++ constructs, if appropriate. */ { diff --git a/gcc/testsuite/g++.dg/tm/template-2.C b/gcc/testsuite/g++.dg/tm/template-2.C new file mode 100644 index 0000000..a05793d --- /dev/null +++ b/gcc/testsuite/g++.dg/tm/template-2.C @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O -std=c++0x -fdump-tree-tmmark" } + +struct TrueFalse +{ +}; + +int global; + +template<typename T> int foo() +{ + return __transaction_atomic (global + 2) + + __transaction_atomic (global + 3); +} + +int f1() +{ + return foo<TrueFalse>(); +} + +/* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 2 "tmmark" } } */ +/* { dg-final { cleanup-tree-dump "tmmark" } } */
This patch fixes the instantiation of transaction expressions. Transaction statements were correctly before via tsubst_expr, so just use this code for expressions in tsubst_copy_and_build too. OK for trunk? commit 08726d496492d5a0fc2b0310983b04689ba17a48 Author: Torvald Riegel <triegel@redhat.com> Date: Sat Nov 19 13:44:27 2011 +0100 Fix instantiation of transaction expressions. gcc/cp/ * pt.c (tsubst_copy_and_build): Handle TRANSACTION_EXPR. gcc/testsuite/ * g++.dg/tm/template-2.C: New test.