From patchwork Tue Apr 15 16:21:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 339316 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 4801714008F for ; Wed, 16 Apr 2014 02:22:58 +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=kzkBrVvxlXzPk0kOddRKIM734hdlueFqkTBJ/nzOOpo WAH3hdDeaa+N++g0C0tPjgWWYJx2YmbwclSZsikqu+J8gUpLa2fXGnvq5Gjansy3 FzTiyrNA24usGuuVhUex7b1fjrWxLwRsV9drp+5+4mlOrR5BtklWok945iWt4qfE = 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=HQekaEatSFrKxOzLXjJNnWrjlf4=; b=YOlGBAVdq/pMCf+gf QOfUFfSqpZvYQV1X4siH2IKA20O0HFpNI2DqgY5U2pLSkoW1j2GgjgdIvjWyKHdH jt/3bemIBLaldwCsu2uhYkM71AUA29+A76eNMnkXtpxkkdjq5FX+ydsp7l1JPiTv 7yJakR6sB9GeNHJDuZZB8LBYO0= Received: (qmail 13474 invoked by alias); 15 Apr 2014 16:22:51 -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 13435 invoked by uid 89); 15 Apr 2014 16:22:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 15 Apr 2014 16:22:44 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s3FGMgVu006725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 15 Apr 2014 16:22:43 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s3FGMe3h027962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 15 Apr 2014 16:22:41 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s3FGMeNF010642; Tue, 15 Apr 2014 16:22:40 GMT Received: from [192.168.1.4] (/79.52.211.175) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Apr 2014 09:22:39 -0700 Message-ID: <534D5C70.6010306@oracle.com> Date: Tue, 15 Apr 2014 18:21:04 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch/RFC] Remove unify_success / unify_invalid unused parameter? X-IsSubscribed: yes Hi, a lot of time ago I noticed that these parameters are unused: should I prepare a ChangeLog for the below or we have stylistic, etc, reasons for keeping the parameters? Thanks, Paolo. PS: I also see many int return types in the various unify* which could as well be bool. Opinions about that? //////////////////// Index: pt.c =================================================================== --- pt.c (revision 209420) +++ pt.c (working copy) @@ -5377,7 +5377,7 @@ has_value_dependent_address (tree op) call.c */ static int -unify_success (bool /*explain_p*/) +unify_success (void) { return 0; } @@ -5392,7 +5392,7 @@ unify_parameter_deduction_failure (bool explain_p, } static int -unify_invalid (bool /*explain_p*/) +unify_invalid (void) { return 1; } @@ -16085,13 +16085,13 @@ check_non_deducible_conversion (tree parm, tree ar type = arg; if (same_type_p (parm, type)) - return unify_success (explain_p); + return unify_success (); if (strict == DEDUCE_CONV) { if (can_convert_arg (type, parm, NULL_TREE, flags, explain_p ? tf_warning_or_error : tf_none)) - return unify_success (explain_p); + return unify_success (); } else if (strict != DEDUCE_EXACT) { @@ -16098,7 +16098,7 @@ check_non_deducible_conversion (tree parm, tree ar if (can_convert_arg (parm, type, TYPE_P (arg) ? NULL_TREE : arg, flags, explain_p ? tf_warning_or_error : tf_none)) - return unify_success (explain_p); + return unify_success (); } if (strict == DEDUCE_EXACT) @@ -16249,11 +16249,11 @@ unify_one_argument (tree tparms, tree targs, tree int arg_strict; if (arg == error_mark_node || parm == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); if (arg == unknown_type_node) /* We can't deduce anything from this, but we might get all the template args from other function args. */ - return unify_success (explain_p); + return unify_success (); /* Implicit conversions (Clause 4) will be performed on a function argument to convert it to the type of the corresponding function @@ -16269,7 +16269,7 @@ unify_one_argument (tree tparms, tree targs, tree && TYPE_P (parm) && !uses_deducible_template_parms (parm)) /* For function parameters with only non-deducible template parameters, just return. */ - return unify_success (explain_p); + return unify_success (); switch (strict) { @@ -16314,7 +16314,7 @@ unify_one_argument (tree tparms, tree targs, tree if (resolve_overloaded_unification (tparms, targs, parm, arg, strict, arg_strict, explain_p)) - return unify_success (explain_p); + return unify_success (); return unify_overload_resolution_failure (explain_p, arg); } @@ -16321,7 +16321,7 @@ unify_one_argument (tree tparms, tree targs, tree arg_expr = arg; arg = unlowered_expr_type (arg); if (arg == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); } arg_strict |= @@ -16548,7 +16548,7 @@ type_unification_real (tree tparms, SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, TREE_VEC_LENGTH (targs)); #endif - return unify_success (explain_p); + return unify_success (); } /* Subroutine of type_unification_real. Args are like the variables @@ -17242,7 +17242,7 @@ unify_pack_expansion (tree tparms, tree targs, tre } } - return unify_success (explain_p); + return unify_success (); } /* Handle unification of the domain of an array. PARM_DOM and ARG_DOM are @@ -17369,12 +17369,12 @@ unify (tree tparms, tree targs, tree parm, tree ar parm = TREE_OPERAND (parm, 0); if (arg == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); if (arg == unknown_type_node || arg == init_list_type_node) /* We can't deduce anything from this, but we might get all the template args from other function args. */ - return unify_success (explain_p); + return unify_success (); /* If PARM uses template parameters, then we can't bail out here, even if ARG == PARM, since we won't record unifications for the @@ -17381,7 +17381,7 @@ unify (tree tparms, tree targs, tree parm, tree ar template parameters. We might need them if we're trying to figure out which of two things is more specialized. */ if (arg == parm && !uses_template_parms (parm)) - return unify_success (explain_p); + return unify_success (); /* Handle init lists early, so the rest of the function can assume we're dealing with a type. */ @@ -17401,7 +17401,7 @@ unify (tree tparms, tree targs, tree parm, tree ar /* We can only deduce from an initializer list argument if the parameter is std::initializer_list or an array; otherwise this is a non-deduced context. */ - return unify_success (explain_p); + return unify_success (); if (TREE_CODE (parm) == ARRAY_TYPE) elttype = TREE_TYPE (parm); @@ -17413,7 +17413,7 @@ unify (tree tparms, tree targs, tree parm, tree ar int elt_strict = strict; if (elt == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); if (!BRACE_ENCLOSED_INITIALIZER_P (elt)) { @@ -17436,7 +17436,7 @@ unify (tree tparms, tree targs, tree parm, tree ar tree max = size_int (CONSTRUCTOR_NELTS (arg)); tree idx = compute_array_index_type (NULL_TREE, max, tf_none); if (idx == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm), idx, explain_p); } @@ -17450,7 +17450,7 @@ unify (tree tparms, tree targs, tree parm, tree ar targ = listify (targ); TREE_VEC_ELT (INNERMOST_TEMPLATE_ARGS (targs), idx) = targ; } - return unify_success (explain_p); + return unify_success (); } /* Immediately reject some pairs that won't unify because of @@ -17485,7 +17485,7 @@ unify (tree tparms, tree targs, tree parm, tree ar /* In a type which contains a nested-name-specifier, template argument values cannot be deduced for template parameters used within the nested-name-specifier. */ - return unify_success (explain_p); + return unify_success (); case TEMPLATE_TYPE_PARM: case TEMPLATE_TEMPLATE_PARM: @@ -17492,7 +17492,7 @@ unify (tree tparms, tree targs, tree parm, tree ar case BOUND_TEMPLATE_TEMPLATE_PARM: tparm = TREE_VALUE (TREE_VEC_ELT (tparms, 0)); if (error_operand_p (tparm)) - return unify_invalid (explain_p); + return unify_invalid (); if (TEMPLATE_TYPE_LEVEL (parm) != template_decl_level (tparm)) @@ -17502,7 +17502,7 @@ unify (tree tparms, tree targs, tree parm, tree ar if (TREE_CODE (arg) == TREE_CODE (parm) && (is_auto (parm) ? is_auto (arg) : same_type_p (parm, arg))) - return unify_success (explain_p); + return unify_success (); else return unify_type_mismatch (explain_p, parm, arg); } @@ -17510,7 +17510,7 @@ unify (tree tparms, tree targs, tree parm, tree ar targ = TREE_VEC_ELT (INNERMOST_TEMPLATE_ARGS (targs), idx); tparm = TREE_VALUE (TREE_VEC_ELT (tparms, idx)); if (error_operand_p (tparm)) - return unify_invalid (explain_p); + return unify_invalid (); /* Check for mixed types and values. */ if ((TREE_CODE (parm) == TEMPLATE_TYPE_PARM @@ -17599,7 +17599,7 @@ unify (tree tparms, tree targs, tree parm, tree ar entire template argument list is a non-deduced context. */ if (PACK_EXPANSION_P (TREE_VEC_ELT (parmvec, i))) - return unify_success (explain_p); + return unify_success (); if (TREE_VEC_LENGTH (argvec) < len - parm_variadic_p) return unify_too_few_arguments (explain_p, @@ -17632,7 +17632,7 @@ unify (tree tparms, tree targs, tree parm, tree ar /* Simple cases: Value already set, does match or doesn't. */ if (targ != NULL_TREE && template_args_equal (targ, arg)) - return unify_success (explain_p); + return unify_success (); else if (targ) return unify_inconsistency (explain_p, parm, targ, arg); } @@ -17651,11 +17651,11 @@ unify (tree tparms, tree targs, tree parm, tree ar arg = cp_build_qualified_type_real (arg, cp_type_quals (arg) & ~cp_type_quals (parm), tf_none); if (arg == error_mark_node) - return unify_invalid (explain_p); + return unify_invalid (); /* Simple cases: Value already set, does match or doesn't. */ if (targ != NULL_TREE && same_type_p (targ, arg)) - return unify_success (explain_p); + return unify_success (); else if (targ) return unify_inconsistency (explain_p, parm, targ, arg); @@ -17688,12 +17688,12 @@ unify (tree tparms, tree targs, tree parm, tree ar return unify_method_type_error (explain_p, arg); TREE_VEC_ELT (INNERMOST_TEMPLATE_ARGS (targs), idx) = arg; - return unify_success (explain_p); + return unify_success (); case TEMPLATE_PARM_INDEX: tparm = TREE_VALUE (TREE_VEC_ELT (tparms, 0)); if (error_operand_p (tparm)) - return unify_invalid (explain_p); + return unify_invalid (); if (TEMPLATE_PARM_LEVEL (parm) != template_decl_level (tparm)) @@ -17742,7 +17742,7 @@ unify (tree tparms, tree targs, tree parm, tree ar else if (uses_template_parms (tparm)) /* We haven't deduced the type of this parameter yet. Try again later. */ - return unify_success (explain_p); + return unify_success (); else return unify_type_mismatch (explain_p, tparm, TREE_TYPE (arg)); @@ -17754,7 +17754,7 @@ unify (tree tparms, tree targs, tree parm, tree ar arg = strip_typedefs_expr (arg); TREE_VEC_ELT (INNERMOST_TEMPLATE_ARGS (targs), idx) = arg; - return unify_success (explain_p); + return unify_success (); case PTRMEM_CST: { @@ -17818,7 +17818,7 @@ unify (tree tparms, tree targs, tree parm, tree ar if (TYPE_DOMAIN (parm) != NULL_TREE) return unify_array_domain (tparms, targs, TYPE_DOMAIN (parm), TYPE_DOMAIN (arg), explain_p); - return unify_success (explain_p); + return unify_success (); case REAL_TYPE: case COMPLEX_TYPE: @@ -17838,7 +17838,7 @@ unify (tree tparms, tree targs, tree parm, tree ar /* As far as unification is concerned, this wins. Later checks will invalidate it if necessary. */ - return unify_success (explain_p); + return unify_success (); /* Types INTEGER_CST and MINUS_EXPR can come from array bounds. */ /* Type INTEGER_CST can come from ordinary constant template args. */ @@ -17849,7 +17849,7 @@ unify (tree tparms, tree targs, tree parm, tree ar if (TREE_CODE (arg) != INTEGER_CST) return unify_template_argument_mismatch (explain_p, parm, arg); return (tree_int_cst_equal (parm, arg) - ? unify_success (explain_p) + ? unify_success () : unify_template_argument_mismatch (explain_p, parm, arg)); case TREE_VEC: @@ -17877,7 +17877,7 @@ unify (tree tparms, tree targs, tree parm, tree ar P contains a pack expansion that is not the last template argument, the entire template argument list is a non-deduced context. */ - return unify_success (explain_p); + return unify_success (); } } @@ -17903,7 +17903,7 @@ unify (tree tparms, tree targs, tree parm, tree ar return unify_pack_expansion (tparms, targs, parm, arg, DEDUCE_EXACT, /*subr=*/true, explain_p); - return unify_success (explain_p); + return unify_success (); } case RECORD_TYPE: @@ -17966,7 +17966,7 @@ unify (tree tparms, tree targs, tree parm, tree ar } else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg)) return unify_type_mismatch (explain_p, parm, arg); - return unify_success (explain_p); + return unify_success (); case METHOD_TYPE: case FUNCTION_TYPE: @@ -18038,7 +18038,7 @@ unify (tree tparms, tree targs, tree parm, tree ar return unify (tparms, targs, DECL_INITIAL (parm), arg, strict, explain_p); if (arg != integral_constant_value (parm)) return unify_template_argument_mismatch (explain_p, parm, arg); - return unify_success (explain_p); + return unify_success (); case FIELD_DECL: case TEMPLATE_DECL: @@ -18062,11 +18062,11 @@ unify (tree tparms, tree targs, tree parm, tree ar case UNDERLYING_TYPE: /* Cannot deduce anything from TYPEOF_TYPE, DECLTYPE_TYPE, or UNDERLYING_TYPE nodes. */ - return unify_success (explain_p); + return unify_success (); case ERROR_MARK: /* Unification fails if we hit an error node. */ - return unify_invalid (explain_p); + return unify_invalid (); case INDIRECT_REF: if (REFERENCE_REF_P (parm)) @@ -18077,7 +18077,7 @@ unify (tree tparms, tree targs, tree parm, tree ar default: /* An unresolved overload is a nondeduced context. */ if (is_overloaded_fn (parm) || type_unknown_p (parm)) - return unify_success (explain_p); + return unify_success (); gcc_assert (EXPR_P (parm)); /* We must be looking at an expression. This can happen with @@ -18103,7 +18103,7 @@ unify (tree tparms, tree targs, tree parm, tree ar && !template_args_equal (parm, arg)) return unify_expression_unequal (explain_p, parm, arg); else - return unify_success (explain_p); + return unify_success (); } } #undef RECUR_AND_CHECK_FAILURE