From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15881 invoked by alias); 28 Oct 2011 14:51:18 -0000 Received: (qmail 15867 invoked by uid 22791); 28 Oct 2011 14:51:17 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Oct 2011 14:50:51 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9SEopjF001073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 28 Oct 2011 10:50:51 -0400 Received: from houston.quesejoda.com (vpn-224-8.phx2.redhat.com [10.3.224.8]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p9SEoopc011823; Fri, 28 Oct 2011 10:50:50 -0400 Message-ID: <4EAAC14A.80908@redhat.com> Date: Fri, 28 Oct 2011 15:23:00 -0000 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0) Gecko/20110927 Thunderbird/7.0 MIME-Version: 1.0 To: Richard Henderson , Torvald Riegel , gcc-patches Subject: [trans-mem] fix C++ transaction_wrap attribute Content-Type: multipart/mixed; boundary="------------050100070207010806060100" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg02671.txt.bz2 This is a multi-part message in MIME format. --------------050100070207010806060100 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 914 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? --------------050100070207010806060100 Content-Type: text/plain; name="curr" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="curr" Content-length: 3756 * 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" } */ --------------050100070207010806060100--