From patchwork Tue Jan 3 17:18:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 134041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5106BB6FA8 for ; Wed, 4 Jan 2012 04:19:24 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326215965; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=A/d39oVol8qgxe7JNznxP6trZTM=; b=Dfl9KgncuozWVpx UId+ZKB3Q1FHj7UppBZIib7TYEw7Sbjxs40d4yWTgnTPIjd7sVb+ad8j448xwrsJ lY1yqiND4wit1sICTzu0E88uvv2L2rQ+tFbowgfEH3FJ/hcJLjRcpKWlA119dvhY iu7xo7ADKpEzXRBdaBUd8pEWr/Dg= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Jp41UHja+ziYix0z1ZkxtdSvlqy9c3aqayMAGCXFugymxPxURqgjroCcvkIuPo hsK8HgNmpL3GtRB00B768BEaLtML6J97OLxc0jaqsFfbs7XY4VONnVWW96O8oV/4 oU8QKGN+gecM5iLZCG91yGY0PKuBttHj7+4UCxkGInW90=; Received: (qmail 8274 invoked by alias); 3 Jan 2012 17:19:17 -0000 Received: (qmail 8265 invoked by uid 22791); 3 Jan 2012 17:19:15 -0000 X-SWARE-Spam-Status: No, hits=-7.6 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; Tue, 03 Jan 2012 17:18:57 +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 q03HIuCt014117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 3 Jan 2012 12:18:56 -0500 Received: from houston.quesejoda.com (vpn-9-188.rdu.redhat.com [10.11.9.188]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q03HItfR019674; Tue, 3 Jan 2012 12:18:55 -0500 Message-ID: <4F03387F.308@redhat.com> Date: Tue, 03 Jan 2012 11:18:55 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches , Richard Henderson Subject: Re: PR middle-end/51696: display indirect function calls properly for trans-mem References: <4F033514.6050904@redhat.com> In-Reply-To: <4F033514.6050904@redhat.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 01/03/12 11:04, Aldy Hernandez wrote: > For the following testcase, we display indirect calls as memory > addresses, which can confuse the user: > > struct list { > void (*compare)(); > } *listPtr; > static void (*compare)(); > __attribute__((transaction_safe)) > static void func () { > listPtr->compare(); > /* ^^^^^^^^^^^^^^^^^^^^^^^^^^ */ > /* error: unsafe function call ‘’.... */ > compare(); > } > > This happens because pp_c_tree_decl_identifier() dumps the memory > address when there is no DECL_NAME associated with the symbol. > > Instead of displaying something like in this particular error, > perhaps we can display "unsafe indirect function call...". > > OK? Whoops, wrong revision of the patch. Revised one here. PR middle-end/51696 * trans-mem.c (diagnose_tm_1): Display indirect calls with no name correctly. Index: testsuite/gcc.dg/tm/pr51696.c =================================================================== --- testsuite/gcc.dg/tm/pr51696.c (revision 0) +++ testsuite/gcc.dg/tm/pr51696.c (revision 0) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +struct list { + void (*compare)(); +} *listPtr; + +static void (*compare)(); + +__attribute__((transaction_safe)) +static void func () { + listPtr->compare(); /* { dg-error "unsafe indirect function call" } */ + compare(); /* { dg-error "unsafe function call" } */ +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 182848) +++ trans-mem.c (working copy) @@ -664,9 +664,16 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi "unsafe function call %qD within " "atomic transaction", fn); else - error_at (gimple_location (stmt), - "unsafe function call %qE within " - "atomic transaction", fn); + { + if (DECL_NAME (fn)) + error_at (gimple_location (stmt), + "unsafe function call %qE within " + "atomic transaction", fn); + else + error_at (gimple_location (stmt), + "unsafe indirect function call within " + "atomic transaction"); + } } else { @@ -675,9 +682,16 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi "unsafe function call %qD within " "% function", fn); else - error_at (gimple_location (stmt), - "unsafe function call %qE within " - "% function", fn); + { + if (DECL_NAME (fn)) + error_at (gimple_location (stmt), + "unsafe function call %qE within " + "% function", fn); + else + error_at (gimple_location (stmt), + "unsafe indirect function call within " + "% function"); + } } } }