diff mbox

[trans-mem] fix C++ transaction_wrap attribute

Message ID 4EAAC14A.80908@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez Oct. 28, 2011, 2:50 p.m. UTC
The C++ front-end gives us a DECL for transaction_wrap attribute's 
argument.  The C front-end OTOH gives us an IDENTIFIER_NODE.  I have no 
idea why this change after the merge, but I have fixed the attribute 
handler to work with both front-ends.

Also, for this case, distilled from testsuite/c-c++-common/tm/wrap-2.c, 
the C++ FE correctly complains that "f4" was not declared in this scope. 
  The C front-end does not.

	void g4(void) __attribute__((transaction_wrap(f4)))

Suffice to say that both front-ends are sufficiently different that we 
should probably have two versions of testsuite/c-c++-common/tm/wrap-2.c.

The following patch fixes the attribute handler to work with both 
front-ends and separates wrap-2.c into C and C++ versions.  With it, the 
wrap-* failures are fixed for C++.

Including the patches I have queued on my end, we are now down to 3 
distinct C++ TM failures.

OK for branch?
* c-family/c-common.c (handle_tm_wrap_attribute): Handle decl
	argument.
	* testsuite/c-c++-common/tm/wrap-2.c: Move...
	* testsuite/gcc.dg/tm/wrap-2.c: ...here.
	* testsuite/g++.dg/tm/wrap-2.C: New.

Comments

Richard Henderson Oct. 28, 2011, 3:23 p.m. UTC | #1
On 10/28/2011 07:50 AM, Aldy Hernandez wrote:
> 	* c-family/c-common.c (handle_tm_wrap_attribute): Handle decl
> 	argument.
> 	* testsuite/c-c++-common/tm/wrap-2.c: Move...
> 	* testsuite/gcc.dg/tm/wrap-2.c: ...here.
> 	* testsuite/g++.dg/tm/wrap-2.C: New.

Ok.


r~
diff mbox

Patch

Index: c-family/c-common.c
===================================================================
--- c-family/c-common.c	(revision 180614)
+++ c-family/c-common.c	(working copy)
@@ -7489,12 +7489,15 @@  handle_tm_wrap_attribute (tree *node, tr
     warning (OPT_Wattributes, "%qE attribute ignored", name);
   else
     {
-      tree wrap_id = TREE_VALUE (args);
-      if (TREE_CODE (wrap_id) != IDENTIFIER_NODE)
+      tree wrap_decl = TREE_VALUE (args);
+      if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE
+	  && TREE_CODE (wrap_decl) != VAR_DECL
+	  && TREE_CODE (wrap_decl) != FUNCTION_DECL)
 	error ("%qE argument not an identifier", name);
       else
 	{
-	  tree wrap_decl = lookup_name (wrap_id);
+	  if (TREE_CODE (wrap_decl) == IDENTIFIER_NODE)
+	    wrap_decl = lookup_name (wrap_decl);
 	  if (wrap_decl && TREE_CODE (wrap_decl) == FUNCTION_DECL)
 	    {
 	      if (lang_hooks.types_compatible_p (TREE_TYPE (decl),
@@ -7504,7 +7507,7 @@  handle_tm_wrap_attribute (tree *node, tr
 		error ("%qD is not compatible with %qD", wrap_decl, decl);
 	    }
 	  else
-	    error ("%qE is not a function", wrap_id);
+	    error ("transaction_wrap argument is not a function");
 	}
     }
 
Index: testsuite/gcc.dg/tm/wrap-2.c
===================================================================
--- testsuite/gcc.dg/tm/wrap-2.c	(revision 0)
+++ testsuite/gcc.dg/tm/wrap-2.c	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+#define W(X)	__attribute__((transaction_wrap(X)))
+void f1(void);
+void f2(int);
+int i3;
+int f7(void);
+
+void g1(void) W(f1);
+void g2(void) W(f2);	/* { dg-error "is not compatible" } */
+void g3(void) W(i3);	/* { dg-error "is not a function" } */
+void g4(void) W(f4);	/* { dg-error "is not a function" } */
+void g5(void) W(1);	/* { dg-error "not an identifier" } */
+void g6(void) W("f1");	/* { dg-error "not an identifier" } */
+void g7(void) W(f7);	/* { dg-error "is not compatible" } */
Index: testsuite/g++.dg/tm/wrap-2.C
===================================================================
--- testsuite/g++.dg/tm/wrap-2.C	(revision 0)
+++ testsuite/g++.dg/tm/wrap-2.C	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+#define W(X)	__attribute__((transaction_wrap(X)))
+void f1(void);
+void f2(int);
+int i3;
+int f7(void);
+
+void g1(void) W(f1);
+void g2(void) W(f2);	/* { dg-error "is not compatible" } */
+void g3(void) W(i3);	/* { dg-error "is not a function" } */
+void g4(void) W(f4);	/* { dg-error "not declared in this scope\|not an identifier" } */
+void g5(void) W(1);	/* { dg-error "not an identifier" } */
+void g6(void) W("f1");	/* { dg-error "not an identifier" } */
+void g7(void) W(f7);	/* { dg-error "is not compatible" } */
Index: testsuite/c-c++-common/tm/wrap-2.c
===================================================================
--- testsuite/c-c++-common/tm/wrap-2.c	(revision 180614)
+++ testsuite/c-c++-common/tm/wrap-2.c	(working copy)
@@ -1,16 +0,0 @@ 
-/* { dg-do compile } */
-/* { dg-options "-fgnu-tm" } */
-
-#define W(X)	__attribute__((transaction_wrap(X)))
-void f1(void);
-void f2(int);
-int i3;
-int f7(void);
-
-void g1(void) W(f1);
-void g2(void) W(f2);	/* { dg-error "is not compatible" } */
-void g3(void) W(i3);	/* { dg-error "is not a function" } */
-void g4(void) W(f4);	/* { dg-error "is not a function" } */
-void g5(void) W(1);	/* { dg-error "not an identifier" } */
-void g6(void) W("f1");	/* { dg-error "not an identifier" } */
-void g7(void) W(f7);	/* { dg-error "is not compatible" } */