From patchwork Fri Mar 11 21:35:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 86460 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 8FA0FB6FBF for ; Sat, 12 Mar 2011 08:35:54 +1100 (EST) Received: (qmail 21297 invoked by alias); 11 Mar 2011 21:35:52 -0000 Received: (qmail 21108 invoked by uid 22791); 11 Mar 2011 21:35:52 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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, 11 Mar 2011 21:35:45 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2BLZZlO025522 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 11 Mar 2011 16:35:35 -0500 Received: from [127.0.0.1] (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2BLZZgo007138; Fri, 11 Mar 2011 16:35:35 -0500 Message-ID: <4D7A95A6.8060605@redhat.com> Date: Fri, 11 Mar 2011 16:35:34 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches List CC: "Joseph S. Myers" Subject: PATCH to attribute_takes_identifier_p for c++/46803 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 In 46803 we have an unknown attribute that apparently takes an identifier as its first argument; since my introduction of attribute_takes_identifier_p, we assume that most attributes do not take an identifier as their first argument. But it won't hurt to assume the contrary for unknown attributes, since we're just going to ignore them anyway. Tested x86_64-pc-linux-gnu, applied to trunk. commit c530bce3d9db3b334ea12bde6cb17e95f0048636 Author: Jason Merrill Date: Fri Mar 11 14:09:30 2011 -0500 PR c++/46803 * c-common.c (attribute_takes_identifier_p): Assume that an unknown attribute takes an identifier. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index f029661..32b9a70 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5665,9 +5665,14 @@ c_init_attributes (void) bool attribute_takes_identifier_p (const_tree attr_id) { - if (is_attribute_p ("mode", attr_id) - || is_attribute_p ("format", attr_id) - || is_attribute_p ("cleanup", attr_id)) + struct attribute_spec *spec = lookup_attribute_spec (attr_id); + if (spec == NULL) + /* Unknown attribute that we'll end up ignoring, return true so we + don't complain about an identifier argument. */ + return true; + else if (!strcmp ("mode", spec->name) + || !strcmp ("format", spec->name) + || !strcmp ("cleanup", spec->name)) return true; else return targetm.attribute_takes_identifier_p (attr_id); diff --git a/gcc/testsuite/g++.dg/ext/attrib40.C b/gcc/testsuite/g++.dg/ext/attrib40.C new file mode 100644 index 0000000..9c3f761 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib40.C @@ -0,0 +1,4 @@ +// PR c++/46803 + +int strftime(char *, int, const char *, const struct tm *) + __attribute__ ((__bounded__(__string__,1,2))); // { dg-warning "ignored" }