From patchwork Mon Mar 25 23:42:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 231028 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 49A982C00EA for ; Tue, 26 Mar 2013 10:42:31 +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:cc:subject:content-type; q=dns; s=default; b=HdXg7LKhF3Qhbm9gsjPY1T0SOEoOTFt6Ho6YeCpHgvR WpOwbxfHtxYG9TDvTDJpNM0jO4vVQ1oP3R8lW+/jMqHh0p01zt+bSqCwPusHN8pj 66XEDfQWuIQvav6wYt/PFczEmrUbofXxsMFnRQ4Azlha/QSEjs9dzQdrIUr175JQ = 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=AqJAHNSHj+v3FN3qrwz/VPNAVAk=; b=x8dTttTHg4vCS8Ji3 wE645WkHPXdkWTmRt8mQSoGTeTp8PAPmd85jBXSomIOEmQsicExIOFQy6tje1tB+ K85/pi7NtZpUOW5Z5vd3v6ig/VSMUf68HTVO792TcqSRCoq5K7mjQCedOIfqMz3B uFroCiTpviWLHQmwfTKzhH1ILs= Received: (qmail 3879 invoked by alias); 25 Mar 2013 23:42:21 -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 3851 invoked by uid 89); 25 Mar 2013 23:42:13 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 25 Mar 2013 23:42:13 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2PNgBYb001629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Mar 2013 23:42:12 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2PNgBrQ027258 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Mar 2013 23:42:11 GMT Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2PNgB0q010432; Mon, 25 Mar 2013 18:42:11 -0500 Received: from [192.168.1.4] (/79.53.234.117) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 Mar 2013 16:42:10 -0700 Message-ID: <5150E0CD.90407@oracle.com> Date: Tue, 26 Mar 2013 00:42:05 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] Small grokdeclarator clean up X-Virus-Found: No Hi again, this one adds a typedef_p to grokdeclarator and uses it everywhere. Paolo. ////////////////////////// 2013-03-25 Paolo Carlini * decl.c (grokdeclarator): Declare typedef_p and use it everywhere. Index: decl.c =================================================================== --- decl.c (revision 196374) +++ decl.c (working copy) @@ -8652,6 +8652,7 @@ grokdeclarator (const cp_declarator *declarator, bool parameter_pack_p = declarator? declarator->parameter_pack_p : false; bool template_type_arg = false; bool template_parm_flag = false; + bool typedef_p = decl_spec_seq_has_spec_p (declspecs, ds_typedef); bool constexpr_p = decl_spec_seq_has_spec_p (declspecs, ds_constexpr); const char *errmsg; @@ -8862,7 +8863,7 @@ grokdeclarator (const cp_declarator *declarator, if (dname && IDENTIFIER_OPNAME_P (dname)) { - if (decl_spec_seq_has_spec_p (declspecs, ds_typedef)) + if (typedef_p) { error ("declaration of %qD as %", dname); return error_mark_node; @@ -8900,7 +8901,7 @@ grokdeclarator (const cp_declarator *declarator, if (name == NULL) name = decl_context == PARM ? "parameter" : "type name"; - if (constexpr_p && decl_spec_seq_has_spec_p (declspecs, ds_typedef)) + if (constexpr_p && typedef_p) { error ("% cannot appear in a typedef declaration"); return error_mark_node; @@ -9198,7 +9199,7 @@ grokdeclarator (const cp_declarator *declarator, /* Issue errors about use of storage classes for parameters. */ if (decl_context == PARM) { - if (decl_spec_seq_has_spec_p (declspecs, ds_typedef)) + if (typedef_p) { error ("typedef declaration invalid in parameter declaration"); return error_mark_node; @@ -9242,7 +9243,7 @@ grokdeclarator (const cp_declarator *declarator, && ((storage_class && storage_class != sc_extern && storage_class != sc_static) - || decl_spec_seq_has_spec_p (declspecs, ds_typedef))) + || typedef_p)) { error ("multiple storage classes in declaration of %qs", name); thread_p = false; @@ -9256,7 +9257,7 @@ grokdeclarator (const cp_declarator *declarator, && (storage_class == sc_register || storage_class == sc_auto)) ; - else if (decl_spec_seq_has_spec_p (declspecs, ds_typedef)) + else if (typedef_p) ; else if (decl_context == FIELD /* C++ allows static class elements. */ @@ -9866,8 +9867,7 @@ grokdeclarator (const cp_declarator *declarator, return error_mark_node; } } - else if (decl_spec_seq_has_spec_p (declspecs, ds_typedef) - && current_class_type) + else if (typedef_p && current_class_type) { error ("cannot declare member %<%T::%s%> within %qT", ctype, name, current_class_type); @@ -9944,8 +9944,7 @@ grokdeclarator (const cp_declarator *declarator, error ("non-member %qs cannot be declared %", name); storage_class = sc_none; } - else if (decl_context == TYPENAME - || decl_spec_seq_has_spec_p (declspecs, ds_typedef)) + else if (decl_context == TYPENAME || typedef_p) { error ("non-object member %qs cannot be declared %", name); storage_class = sc_none; @@ -9975,7 +9974,7 @@ grokdeclarator (const cp_declarator *declarator, } /* If this is declaring a typedef name, return a TYPE_DECL. */ - if (decl_spec_seq_has_spec_p (declspecs, ds_typedef) && decl_context != TYPENAME) + if (typedef_p && decl_context != TYPENAME) { tree decl;