From patchwork Mon Apr 7 21:00:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 337538 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 DD9081400A3 for ; Tue, 8 Apr 2014 07:00:33 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=oPCiEv3WF/9D sTncQ+RxGRKEz7Fx8xqTavJ7I4EKAOLCOZrh5IRHkOO7N2P03MuGwhnCHP+BNiNs 9P62VDYVJLD05aAxf1EDGyEMgZ25Ib5HCCBsSiq71kWfu97QOzI2ialq+hmz/seK g6Vt9PL11h/JGiAMEFFHvoKBRip7eJg= 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:from :to:cc:subject:date:message-id; s=default; bh=ur7J4ZYki7mHpKuzth nYANJaQdQ=; b=i5hzfl6CkVbWmTCIVeTkwEmi7kgEygb6XOrwDgRFFMDHFuNPKB 6QSdxHxjDx+9vlXVPQ4nbb+2Ur1vyLJ/zs3XKaW0/s/mvSeKb5QCGEmzKwlitu3p oIyIwoDBS1ltzR/x7TQuYzuN2Mwn+GlxS0QLlzrtDkG8bSi6SsEWQgtq4= Received: (qmail 22764 invoked by alias); 7 Apr 2014 21:00:25 -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 22722 invoked by uid 89); 7 Apr 2014 21:00:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-qa0-f51.google.com Received: from mail-qa0-f51.google.com (HELO mail-qa0-f51.google.com) (209.85.216.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 07 Apr 2014 21:00:24 +0000 Received: by mail-qa0-f51.google.com with SMTP id j7so6459023qaq.38 for ; Mon, 07 Apr 2014 14:00:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ktJk7sbA+90U0OJIJYkRpcqsbPqsQ6qvvI5wGoGUekU=; b=J9aq9D6m5Cyz5PYqkzCwVryBGj/28OPmRq09KuIZulu8j1yTIsdvWLpFJMApWlR+bj gTZN9kw0CWck+uIQiiDoBQq7eJLACT7ckhv2ZgD87B0pk8w78M4zKp135HB7D/Yy4W+p HFKshp9CCcxlRmGIR6WPCWggqVqpS3s+WFJka/c97jynq2692w0Z5O7nCtYWEN04UVVD ChLUDCfa+DnNkzXINqMTPOtlAj1H0eW64Tr9SxQ9mUxliADAdhLyFLQKxjs0aZoLJ0fL yZ58zkv166De0hcAoheB1YXwLnshyotSVP+cQuKyIygEh+zYUbK0bKMpEdLrv8kxE0fD 24FQ== X-Gm-Message-State: ALoCoQni1YzXRZ+YxomLiOzL4giQx2pOsfot3Ljaj6CtLSVlXSSdFV3v8NYBgbc9+DtvnK6hQo8N X-Received: by 10.224.30.134 with SMTP id u6mr18762089qac.50.1396904422036; Mon, 07 Apr 2014 14:00:22 -0700 (PDT) Received: from localhost.localdomain (ool-4353a9c4.dyn.optonline.net. [67.83.169.196]) by mx.google.com with ESMTPSA id k9sm36394531qat.18.2014.04.07.14.00.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Apr 2014 14:00:21 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] Fix PR c++/60765 Date: Mon, 7 Apr 2014 17:00:09 -0400 Message-Id: <1396904409-24126-1-git-send-email-patrick@parcs.ath.cx> Hi, This patch teaches the C++ frontend how to handle function attributes attached to pointer-to-member-function declarations. I bootstrapped and regtested this patch on x86_64-unknown-linux-gnu. 2014-04-05 Patrick Palka PR c++/60765 * decl2.c (cplus_decl_attributes): Handle pointer-to-member-function declarations. --- gcc/cp/decl2.c | 10 +++++++++- gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C | 2 +- gcc/testsuite/g++.dg/ext/attrib49.C | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib49.C diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 80f15a4..91a75f3 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1427,7 +1427,15 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags) if (TREE_CODE (*decl) == TEMPLATE_DECL) decl = &DECL_TEMPLATE_RESULT (*decl); - decl_attributes (decl, attributes, flags); + if (TREE_TYPE (*decl) && TYPE_PTRMEMFUNC_P (TREE_TYPE (*decl))) + { + attributes + = decl_attributes (decl, attributes, flags | ATTR_FLAG_FUNCTION_NEXT); + decl_attributes (&TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (*decl)), + attributes, flags); + } + else + decl_attributes (decl, attributes, flags); if (TREE_CODE (*decl) == TYPE_DECL) SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl)); diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C index 2aae9ca..131af36 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-36-1.C @@ -6,6 +6,6 @@ typedef int (*F [[gnu::warn_unused_result]]) (int); typedef int (*F2 [[gnu::warn_unused_result]]) (int); -typedef int (S::*F3 [[gnu::warn_unused_result]]) (int); // { dg-warning "only applies to function types" } +typedef int (S::*F3 [[gnu::warn_unused_result]]) (int); typedef int [[gnu::warn_unused_result]] (*F5) (int); // { dg-warning "ignored" } diff --git a/gcc/testsuite/g++.dg/ext/attrib49.C b/gcc/testsuite/g++.dg/ext/attrib49.C new file mode 100644 index 0000000..99c6154 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib49.C @@ -0,0 +1,20 @@ +// PR c++/60765 +// { dg-options "-Wall -Wunused-parameter" } + +struct foo +{ +} x; + +void (foo::*g) (int *) __attribute__ ((nonnull (2))); + +void +fun1 (void (foo::*f) (int *) __attribute__ ((nonnull (2)))) +{ + (x.*f) ((int *) 0); // { dg-warning "null argument" } +} + +void +fun2 (void (foo::*f) () __attribute__ ((nonnull, unused))) // { dg-bogus "unused" } +{ + (x.*g) ((int *) 0); // { dg-warning "null argument" } +}