[patch] Fix instantiation of transaction expressions.

Torvald Riegel triegel@redhat.com
Mon Nov 21 21:06:00 GMT 2011


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?
-------------- next part --------------
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.

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" } } */


More information about the Gcc-patches mailing list