From patchwork Sun Mar 31 10:26:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 232595 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 5AF082C009C for ; Sun, 31 Mar 2013 21:26:43 +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=wusQYT3mkqS5qH8QppvvRMSPAqir5Juiw5a/d7FiFh1/9m cDDUIbGdlmEtSJ4QTeD7oIlc02fJ3i+sRo4mqOTew3RG7L3S/QZjPGVaPE/5Vxo1 ZzzoKk1rAKVaViPKjK3UsobynEF9WmcMgJEqFO2EqJ43RvXZtW5dedTpmZi30= 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=rlOrxK/tUzah8ImaRp3LnUSkzb8=; b=tPOtYFuC74YM5KXxvIQY FrWneYW7/rs41PFCnTp5H8+2coglQwQjnHhYIYa0ijStIAX5YtiS8jBCHUyWe8eg Vb8D0NCVtqwAE+sltdOqiqk1HFjfhX09TNQRzedfXkoNgoy0TAa+VUY+aw5UkPdh 8tj+EHEMQEgkIarcUyBHt+w= Received: (qmail 7470 invoked by alias); 31 Mar 2013 10:26:34 -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 7433 invoked by uid 89); 31 Mar 2013 10:26:23 -0000 X-Spam-SWARE-Status: No, score=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, TW_FN autolearn=ham version=3.3.1 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; Sun, 31 Mar 2013 10:26:20 +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 r2VAQH24022993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 31 Mar 2013 10:26:18 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2VAQGv1012979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 31 Mar 2013 10:26:17 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2VAQG2b009990 for ; Sun, 31 Mar 2013 05:26:16 -0500 Received: from [192.168.1.4] (/79.36.30.232) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 31 Mar 2013 03:26:16 -0700 Message-ID: <51580F46.9010503@oracle.com> Date: Sun, 31 Mar 2013 12:26:14 +0200 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" Subject: [C++ Patch] Use DECL_DECLARES_TYPE_P, DECL_DECLARES_FUNCTION_P more X-Virus-Found: No Hi, just more straightforward uses of existing predicates. I'm going to boot & test and commit as obvious. Thanks, Paolo. //////////////////// 2013-03-31 Paolo Carlini * decl2.c (collect_candidates_for_java_method_aliases): Use DECL_CLASS_SCOPE_P. * name-lookup.c (pushtag_1) Use TYPE_FUNCTION_SCOPE_P. (pushdecl_maybe_friend_1): Use DECL_DECLARES_FUNCTION_P. * decl.c (duplicate_decls): Likewise. * parser.c (cp_parser_template_declaration_after_export): Likewise, also DECL_DECLARES_TYPE_P. * pt.c (instantiate_class_template_1): Likewise. * search.c (lookup_field_1): Use DECL_DECLARES_TYPE_P. (lookup_field_r): Likewise. (friend_accessible_p): Use DECL_DECLARES_FUNCTION_P. (lookup_fnfields_slot_nolazy): Likewise. * semantics.c (finish_member_declaration): Likewise. * typeck.c (convert_for_initialization): Use TYPE_REFFN_P. Index: decl.c =================================================================== --- decl.c (revision 197280) +++ decl.c (working copy) @@ -2063,8 +2063,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl); } /* Only functions have these fields. */ - if (TREE_CODE (newdecl) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (newdecl)) + if (DECL_DECLARES_FUNCTION_P (newdecl)) { DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl); olddecl_friend = DECL_FRIEND_P (olddecl); Index: decl2.c =================================================================== --- decl2.c (revision 197280) +++ decl2.c (working copy) @@ -3665,8 +3665,7 @@ collect_candidates_for_java_method_aliases (void) { tree fndecl = node->symbol.decl; - if (DECL_CONTEXT (fndecl) - && TYPE_P (DECL_CONTEXT (fndecl)) + if (DECL_CLASS_SCOPE_P (fndecl) && TYPE_FOR_JAVA (DECL_CONTEXT (fndecl)) && TARGET_USE_LOCAL_THUNK_ALIAS_P (fndecl)) { Index: name-lookup.c =================================================================== --- name-lookup.c (revision 197280) +++ name-lookup.c (working copy) @@ -887,7 +887,7 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend) add_decl_to_level (x, NAMESPACE_LEVEL (CP_DECL_CONTEXT (t))); } - if (TREE_CODE (t) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (t)) + if (DECL_DECLARES_FUNCTION_P (t)) check_default_args (t); if (t != x || DECL_FUNCTION_TEMPLATE_P (t)) @@ -5823,8 +5823,7 @@ pushtag_1 (tree name, tree type, tag_scope scope) convenient way. (It's otherwise tricky to find a member function definition it's only pointed to from within a local class.) */ - if (TYPE_CONTEXT (type) - && TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL) + if (TYPE_FUNCTION_SCOPE_P (type)) { if (processing_template_decl) { Index: parser.c =================================================================== --- parser.c (revision 197280) +++ parser.c (working copy) @@ -21983,8 +21983,7 @@ cp_parser_template_declaration_after_export (cp_pa decl = finish_member_template_decl (decl); } else if (friend_p && decl - && (TREE_CODE (decl) == TYPE_DECL - || DECL_TYPE_TEMPLATE_P (decl))) + && DECL_DECLARES_TYPE_P (decl)) make_friend_class (current_class_type, TREE_TYPE (decl), /*complain=*/true); } @@ -21998,7 +21997,7 @@ cp_parser_template_declaration_after_export (cp_pa /* Check the template arguments for a literal operator template. */ if (decl - && (TREE_CODE (decl) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (decl)) + && DECL_DECLARES_FUNCTION_P (decl) && UDLIT_OPER_P (DECL_NAME (decl))) { bool ok = true; @@ -22034,8 +22033,7 @@ cp_parser_template_declaration_after_export (cp_pa (Even though there is no definition, there might be default arguments that need handling.) */ if (member_p && decl - && (TREE_CODE (decl) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (decl))) + && DECL_DECLARES_FUNCTION_P (decl)) vec_safe_push (unparsed_funs_with_definitions, decl); } Index: pt.c =================================================================== --- pt.c (revision 197280) +++ pt.c (working copy) @@ -8786,8 +8786,7 @@ instantiate_class_template_1 (tree type) pushtag (name, newtag, /*tag_scope=*/ts_current); } } - else if (TREE_CODE (t) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (t)) + else if (DECL_DECLARES_FUNCTION_P (t)) { /* Build new TYPE_METHODS. */ tree r; Index: search.c =================================================================== --- search.c (revision 197280) +++ search.c (working copy) @@ -424,8 +424,7 @@ lookup_field_1 (tree type, tree name, bool want_ty do field = fields[i--]; while (i >= lo && DECL_NAME (fields[i]) == name); - if (TREE_CODE (field) != TYPE_DECL - && !DECL_TYPE_TEMPLATE_P (field)) + if (!DECL_DECLARES_TYPE_P (field)) field = NULL_TREE; } else @@ -478,9 +477,7 @@ lookup_field_1 (tree type, tree name, bool want_ty } if (DECL_NAME (decl) == name - && (!want_type - || TREE_CODE (decl) == TYPE_DECL - || DECL_TYPE_TEMPLATE_P (decl))) + && (!want_type || DECL_DECLARES_TYPE_P (decl))) return decl; } /* Not found. */ @@ -777,8 +774,7 @@ friend_accessible_p (tree scope, tree decl, tree b if (!scope) return 0; - if (TREE_CODE (scope) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (scope)) + if (DECL_DECLARES_FUNCTION_P (scope)) befriending_classes = DECL_BEFRIENDING_CLASSES (scope); else if (TYPE_P (scope)) befriending_classes = CLASSTYPE_BEFRIENDING_CLASSES (scope); @@ -796,8 +792,7 @@ friend_accessible_p (tree scope, tree decl, tree b if (protected_accessible_p (decl, t, binfo)) return 1; - if (TREE_CODE (scope) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (scope)) + if (DECL_DECLARES_FUNCTION_P (scope)) { /* Perhaps this SCOPE is a member of a class which is a friend. */ @@ -1059,8 +1054,7 @@ lookup_field_r (tree binfo, void *data) /* If we're looking up a type (as with an elaborated type specifier) we ignore all non-types we find. */ - if (lfi->want_type && TREE_CODE (nval) != TYPE_DECL - && !DECL_TYPE_TEMPLATE_P (nval)) + if (lfi->want_type && !DECL_DECLARES_TYPE_P (nval)) { if (lfi->name == TYPE_IDENTIFIER (type)) { @@ -1509,8 +1503,7 @@ lookup_fnfields_slot_nolazy (tree type, tree name) int class_method_index_for_fn (tree class_type, tree function) { - gcc_assert (TREE_CODE (function) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (function)); + gcc_assert (DECL_DECLARES_FUNCTION_P (function)); return lookup_fnfields_1 (class_type, DECL_CONSTRUCTOR_P (function) ? ctor_identifier : Index: semantics.c =================================================================== --- semantics.c (revision 197280) +++ semantics.c (working copy) @@ -2741,8 +2741,7 @@ finish_member_declaration (tree decl) /* Put functions on the TYPE_METHODS list and everything else on the TYPE_FIELDS list. Note that these are built up in reverse order. We reverse them (to obtain declaration order) in finish_struct. */ - if (TREE_CODE (decl) == FUNCTION_DECL - || DECL_FUNCTION_TEMPLATE_P (decl)) + if (DECL_DECLARES_FUNCTION_P (decl)) { /* We also need to add this function to the CLASSTYPE_METHOD_VEC. */ Index: typeck.c =================================================================== --- typeck.c (revision 197280) +++ typeck.c (working copy) @@ -7963,8 +7963,7 @@ convert_for_initialization (tree exp, tree type, t && (TREE_CODE (type) != REFERENCE_TYPE || TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE)) || (TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE - && (TREE_CODE (type) != REFERENCE_TYPE - || TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE)) + && !TYPE_REFFN_P (type)) || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE) rhs = decay_conversion (rhs, complain);