* [trans-mem] fix C++ transaction_wrap attribute
@ 2011-10-28 15:23 Aldy Hernandez
2011-10-28 15:42 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2011-10-28 15:23 UTC (permalink / raw)
To: Richard Henderson, Torvald Riegel, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 914 bytes --]
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?
[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 3756 bytes --]
* 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.
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" } */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [trans-mem] fix C++ transaction_wrap attribute
2011-10-28 15:23 [trans-mem] fix C++ transaction_wrap attribute Aldy Hernandez
@ 2011-10-28 15:42 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2011-10-28 15:42 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: Torvald Riegel, gcc-patches
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~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-28 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-28 15:23 [trans-mem] fix C++ transaction_wrap attribute Aldy Hernandez
2011-10-28 15:42 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).