===================================================================
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -fopenmp" } */
+
+__attribute__ ((transaction_pure))
+unsigned long rdtsc();
+
+typedef struct ENTER_EXIT_TIMES
+{
+ unsigned long enter;
+} times_t;
+
+void ParClassify()
+{
+ void * Parent;
+#pragma omp parallel private(Parent)
+ {
+ times_t inside;
+ __transaction [[atomic]] {
+ inside.enter = rdtsc();
+ }
+ }
+}
===================================================================
@@ -4683,7 +4683,18 @@ begin_transaction_stmt (location_t loc,
void
finish_transaction_stmt (tree stmt, tree compound_stmt, int flags)
{
- TRANSACTION_EXPR_BODY (stmt) = pop_stmt_list (TRANSACTION_EXPR_BODY (stmt));
+ tree body = pop_stmt_list (TRANSACTION_EXPR_BODY (stmt));
+
+ /* Wrap the transaction body in a BIND_EXPR so we have a context
+ where to put decls for OpenMP. */
+ if (TREE_CODE (body) != BIND_EXPR)
+ {
+ body = build3 (BIND_EXPR, void_type_node, NULL, body, NULL);
+ TREE_SIDE_EFFECTS (body) = 1;
+ SET_EXPR_LOCATION (body, EXPR_LOCATION (stmt));
+ }
+
+ TRANSACTION_EXPR_BODY (stmt) = body;
TRANSACTION_EXPR_OUTER (stmt) = (flags & TM_STMT_ATTR_OUTER) != 0;
TRANSACTION_EXPR_RELAXED (stmt) = (flags & TM_STMT_ATTR_RELAXED) != 0;
===================================================================
@@ -10281,9 +10281,20 @@ c_finish_omp_clauses (tree clauses)
/* Create a transaction node. */
tree
-c_finish_transaction (location_t loc, tree block, int flags)
+c_finish_transaction (location_t loc, tree body, int flags)
{
- tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
+ tree stmt;
+
+ /* Wrap the transaction body in a BIND_EXPR so we have a context
+ where to put decls for OpenMP. */
+ if (TREE_CODE (body) != BIND_EXPR)
+ {
+ body = build3 (BIND_EXPR, void_type_node, NULL, body, NULL);
+ TREE_SIDE_EFFECTS (body) = 1;
+ SET_EXPR_LOCATION (body, loc);
+ }
+
+ stmt = build_stmt (loc, TRANSACTION_EXPR, body);
if (flags & TM_STMT_ATTR_OUTER)
TRANSACTION_EXPR_OUTER (stmt) = 1;
if (flags & TM_STMT_ATTR_RELAXED)