From patchwork Sun Apr 7 17:14:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 234510 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 85A5E2C00BA for ; Mon, 8 Apr 2013 03:14:53 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=mvjELfce6Noc3c6a75ISqAbL6lauB8mC40vPKlPihDB xwJngW0WD/NlzFp5QkGTU+uHM/wkfEr4OtljG8oQqGhA47KqBOj6fGZIP5+9G+O2 MZakD3GkM35+O+yUFiCtCSNsZvv3dZZUF19MDcYuqzitpg2dArVK9UcWUZ6i9FsI = 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:cc:subject:content-type; s=default; bh=Hu782iJouzO1UhT/CKZusjVem+k=; b=VOg1GJ1n/vw+4DW0b bfzn3185hP5sOolbSR2o+oPH25xnWshmSBrutgpH6hsX6tYHQbUFlC6rd85oV01b 7Z0MwtNLL5BWhwraMQceiFulIAHmEnbASH/Db9PKV6NXrshB07rckQbliKpDwnWa kX7Gfpe5TQ8n686mw9aeu9EkD0= Received: (qmail 3226 invoked by alias); 7 Apr 2013 17:14:47 -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 3212 invoked by uid 89); 7 Apr 2013 17:14:46 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 07 Apr 2013 17:14:44 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r37HEgGd012429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 7 Apr 2013 13:14:42 -0400 Received: from [10.3.113.58] (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r37HEfmQ003903; Sun, 7 Apr 2013 13:14:42 -0400 Message-ID: <5161A981.8060101@redhat.com> Date: Sun, 07 Apr 2013 13:14:41 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:22.0) Gecko/20100101 Thunderbird/22.0a2 MIME-Version: 1.0 To: gcc-patches List CC: Dodji Seketeli Subject: C++ PATCH to fix [[noreturn]] X-Virus-Found: No I got a note yesterday from someone trying out GCC 4.8 that noted that the compiler gave the "attribute ignored" warning for all their uses of [[noreturn]], which is one of the attributes described in the standard. Fixing this was a simple matter of mapping it onto the GNU noreturn attribute, which has the same semantics. Tested x86_64-pc-linux-gnu, applying to trunk and 4.8. commit 3a7e7345f4ed48d366a17cffa5addfa587d43ced Author: Jason Merrill Date: Sat Apr 6 21:18:01 2013 -0400 * parser.c (cp_parser_std_attribute): Treat [[noreturn]] like GNU noreturn attribute. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a32f1c3..ff1341a 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -20806,8 +20806,13 @@ cp_parser_std_attribute (cp_parser *parser) token = cp_lexer_peek_token (parser->lexer); } else - attribute = build_tree_list (build_tree_list (NULL_TREE, attr_id), - NULL_TREE); + { + attribute = build_tree_list (build_tree_list (NULL_TREE, attr_id), + NULL_TREE); + /* C++11 noreturn attribute is equivalent to GNU's. */ + if (is_attribute_p ("noreturn", attr_id)) + TREE_PURPOSE (TREE_PURPOSE (attribute)) = get_identifier ("gnu"); + } /* Now parse the optional argument clause of the attribute. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C index bad33d6..dff46b4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C @@ -3,17 +3,17 @@ // Test for syntax support of various attribute permutations. int -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } one [[gnu::unused]] (void); -int one_third [[gnu::noreturn]] [[gnu::unused]] (void); +int one_third [[noreturn]] [[gnu::unused]] (void); int [[gnu::unused]] one_half(); // { dg-warning "ignored" } static -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } void two [[gnu::unused]] (void) {} @@ -21,10 +21,10 @@ void two [[gnu::unused]] (void) {} [[gnu::unused]] int five(void) -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } {} -[[gnu::noreturn]] +[[noreturn]] void six (void) ;