From patchwork Wed Jan 8 09:05:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Alfonsi X-Patchwork-Id: 308100 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1617C2C0078 for ; Wed, 8 Jan 2014 20:05:30 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=WciF0S3nYqr9ohQTfUOpEUxw01IWMCVDVbUu+lcBLdmiIc s51MfD67BDpebK5CGMMIph9SLKOmIZk4DA1yTO4V1DAw+F1NhRaeGo0lXqEWhett SfksBrksvP/F2dv8XkN/89+nKG2mKH0mgotpzOiqdBzhupeSSETUzTM2/kLoQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=vR7m6/0MxLrG1xVUXPg4TRCgwB8=; b=uMCAcOIGeI//XA3AUaol Uy6JMhuAVENFlyU+LS7BhbAlZ692+yhH8eP+yP1NWbZO6rrj2M6mioQy/SQxsqr+ SHRTaT1ZyLQPsvP1LMyYjEjZ8MLtrvuN3yaoE7+nLBm53ANGOGimNRtAfyhPIwKY y5TaetGW6G7El6M0pCoWSik= Received: (qmail 6578 invoked by alias); 8 Jan 2014 09:05:22 -0000 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 Received: (qmail 6564 invoked by uid 89); 8 Jan 2014 09:05:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_20 autolearn=ham version=3.3.2 X-HELO: eu1sys200aog118.obsmtp.com Received: from eu1sys200aog118.obsmtp.com (HELO eu1sys200aog118.obsmtp.com) (207.126.144.145) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) SMTP; Wed, 08 Jan 2014 09:05:19 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKUs0Uy7rgjNfhS/WjoWKUZPPQ3FGiJ500@postini.com; Wed, 08 Jan 2014 09:05:18 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4F127105 for ; Wed, 8 Jan 2014 09:04:31 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas2.st.com [10.75.90.16]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8285D155CC for ; Wed, 8 Jan 2014 08:51:30 +0000 (GMT) Received: from [164.129.122.168] (164.129.122.168) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.297.1; Wed, 8 Jan 2014 10:05:12 +0100 Message-ID: <52CD14C8.5050305@st.com> Date: Wed, 8 Jan 2014 10:05:12 +0100 From: Laurent Alfonsi User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration All, I was looking at PR49718. I have enclosed a simple fix for this bug report. 2014-01-07 Laurent Alfonsi * c-family/c-common.c (handle_no_instrument_function_attribute): Allow no_instrument_function attribute in class member definition/declaration. Looking at the implementation of the function attributes, I see no reason anymore to keep this error message. Let me know if I missed something. I have also added a testcase in the enclosed patch. 2014-01-07 Laurent Alfonsi PR c++/49718 * g++.dg/pr49718.C: New gcc/g++/libstdc++ testsuites are ok on x86-64. Ok for trunk ? Regards, Laurent From 141d2bcfeab5e0635c7f4e362387fd5b1b9494e6 Mon Sep 17 00:00:00 2001 From: Laurent ALFONSI Date: Tue, 7 Jan 2014 16:26:04 +0100 Subject: [PATCH] Fix PR49718 : allow no_instrument_function attribute in class member definition/declaration --- gcc/c-family/c-common.c | 6 ------ gcc/testsuite/g++.dg/pr49718.C | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr49718.C diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 8ecb70c..17fcb0d 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7929,12 +7929,6 @@ handle_no_instrument_function_attribute (tree *node, tree name, "%qE attribute applies only to functions", name); *no_add_attrs = true; } - else if (DECL_INITIAL (decl)) - { - error_at (DECL_SOURCE_LOCATION (decl), - "can%'t set %qE attribute after definition", name); - *no_add_attrs = true; - } else DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1; diff --git a/gcc/testsuite/g++.dg/pr49718.C b/gcc/testsuite/g++.dg/pr49718.C new file mode 100644 index 0000000..07cac8c --- /dev/null +++ b/gcc/testsuite/g++.dg/pr49718.C @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -finstrument-functions" } */ +/* { dg-final { scan-assembler-times "__cyg_profile_func_enter" 1} } */ + +#define NOINSTR __attribute__((no_instrument_function)) + +struct t +{ + public: + /* Function code should be instrumented */ + __attribute__((noinline)) t() {} + + /* Function t::a() should not be instrumented */ + NOINSTR void a(){ + } + /* Function t::b() should not be instrumented */ + void NOINSTR b(){ + } + /* Function t::c() should not be instrumented */ + void c() NOINSTR { + } + /* Function t::d() should not be instrumented */ + void d() NOINSTR; +}; + +void t::d() +{ +} + +/* Function call_all_functions() should not be instrumented */ +struct t call_all_functions() __attribute__((no_instrument_function)); +struct t call_all_functions() +{ + struct t a; /* Constructor not inlined */ + a.a(); /* Inlined t::a() should not be instrumented */ + a.b(); /* Inlined t::b() should not be instrumented */ + a.c(); /* Inlined t::c() should not be instrumented */ + a.d(); /* Inlined t::d() should not be instrumented */ + return a; +} + -- 1.8.4.1