From: Jason Merrill Date: Tue, 1 Nov 2022 02:18:58 +0000 (-0400) Subject: Merge remote-tracking branch 'origin/master' into devel/c++-contracts X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfcb6e7373095d776eeb505f6d1a7d04ada21a3c;p=thirdparty%2Fgcc.git Merge remote-tracking branch 'origin/master' into devel/c++-contracts --- bfcb6e7373095d776eeb505f6d1a7d04ada21a3c diff --cc gcc/cp/cp-tree.h index 4b5d14f6a298,6d84514e4c0f..f4104c8751df --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@@ -7572,13 -7446,11 +7550,13 @@@ extern tree get_function_template_dec extern tree resolve_nondeduced_context (tree, tsubst_flags_t); extern tree resolve_nondeduced_context_or_error (tree, tsubst_flags_t); extern hashval_t iterative_hash_template_arg (tree arg, hashval_t val); - extern tree coerce_template_parms (tree, tree, tree); - extern tree coerce_template_parms (tree, tree, tree, tsubst_flags_t); + extern tree coerce_template_parms (tree, tree, tree, tsubst_flags_t, + bool = true); extern tree canonicalize_type_argument (tree, tsubst_flags_t); +extern void register_local_identity (tree); extern void register_local_specialization (tree, tree); extern tree retrieve_local_specialization (tree); +extern void register_parameter_specializations (tree, tree); extern tree extract_fnparm_pack (tree, tree *); extern tree template_parm_to_arg (tree); extern tree dguide_name (tree); diff --cc gcc/cp/typeck.cc index 7a1ecb2595a3,2e0fd8fbf170..50185a0fac8f --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@@ -11246,15 -11247,20 +11247,26 @@@ check_return_expr (tree retval, bool *n if (processing_template_decl) return saved_retval; + /* A naive attempt to reduce the number of -Wdangling-reference false + positives: if we know that this function can return a variable with + static storage duration rather than one of its parameters, suppress + the warning. */ + if (warn_dangling_reference + && TYPE_REF_P (functype) + && bare_retval + && VAR_P (bare_retval) + && TREE_STATIC (bare_retval)) + suppress_warning (current_function_decl, OPT_Wdangling_reference); + /* Actually copy the value returned into the appropriate location. */ if (retval && retval != result) - retval = cp_build_init_expr (result, retval); + { + /* If there's a postcondition for a scalar return value, wrap + retval in a call to the postcondition function. */ + if (tree post = apply_postcondition_to_return (retval)) + retval = post; + retval = cp_build_init_expr (result, retval); + } if (tree set = maybe_set_retval_sentinel ()) retval = build2 (COMPOUND_EXPR, void_type_node, retval, set);