diff options
Diffstat (limited to 'gcc/cp/pt.cc')
-rw-r--r-- | gcc/cp/pt.cc | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d63fa68..acfeb81 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -6952,14 +6952,22 @@ convert_nontype_argument_function (tree type, tree expr, { auto_diagnostic_group d; location_t loc = cp_expr_loc_or_input_loc (expr); - error_at (loc, "%qE is not a valid template argument for type %qT", - expr, type); - if (TYPE_PTR_P (type)) - inform (loc, "it must be the address of a function " - "with external linkage"); + tree c; + if (cxx_dialect >= cxx17 + && (c = cxx_constant_value (fn), + c == error_mark_node)) + ; else - inform (loc, "it must be the name of a function with " - "external linkage"); + { + error_at (loc, "%qE is not a valid template argument for " + "type %qT", expr, type); + if (TYPE_PTR_P (type)) + inform (loc, "it must be the address of a function " + "with external linkage"); + else + inform (loc, "it must be the name of a function with " + "external linkage"); + } } return NULL_TREE; } @@ -7402,22 +7410,22 @@ invalid_tparm_referent_p (tree type, tree expr, tsubst_flags_t complain) /* Null pointer values are OK in C++11. */; else { - if (VAR_P (expr)) - { - if (complain & tf_error) - error ("%qD is not a valid template argument " - "because %qD is a variable, not the address of " - "a variable", expr, expr); - return true; - } + tree c; + if (!(complain & tf_error)) + ; + else if (cxx_dialect >= cxx17 + && (c = cxx_constant_value (expr), + c == error_mark_node)) + ; + else if (VAR_P (expr)) + error ("%qD is not a valid template argument " + "because %qD is a variable, not the address of " + "a variable", expr, expr); else - { - if (complain & tf_error) - error ("%qE is not a valid template argument for %qT " - "because it is not the address of a variable", - expr, type); - return true; - } + error ("%qE is not a valid template argument for %qT " + "because it is not the address of a variable", + expr, type); + return true; } } return false; @@ -14916,6 +14924,9 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, argvec = NULL_TREE; } + /* Make sure tsubst_decl substitutes all the parameters. */ + cp_evaluated ev; + tree closure = (lambda_fntype ? TYPE_METHOD_BASETYPE (lambda_fntype) : NULL_TREE); tree ctx = closure ? closure : DECL_CONTEXT (t); @@ -19590,7 +19601,8 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) finish_static_assert (condition, message, STATIC_ASSERT_SOURCE_LOCATION (t), - /*member_p=*/false, /*show_expr_p=*/true); + /*member_p=*/false, /*show_expr_p=*/true, + CONSTEVAL_BLOCK_P (t)); } break; @@ -20494,11 +20506,6 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) r = error_mark_node; else { - /* The body of a lambda-expression is not a subexpression of the - enclosing expression. Parms are to have DECL_CHAIN tsubsted, - which would be skipped if cp_unevaluated_operand. */ - cp_evaluated ev; - /* Fix the type of 'this'. For static and xobj member functions we use this to transport the lambda's closure type. It appears that in the regular case the @@ -20524,6 +20531,10 @@ tsubst_lambda_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) /* Let finish_function set this. */ DECL_DECLARED_CONSTEXPR_P (fn) = false; + /* The body of a lambda-expression is not a subexpression of the + enclosing expression. */ + cp_evaluated ev; + bool nested = cfun; if (nested) push_function_context (); @@ -31214,14 +31225,8 @@ alias_ctad_tweaks (tree tmpl, tree uguides) /* Substitute the deduced arguments plus the rewritten template parameters into f to get g. This covers the type, copyness, guideness, and explicit-specifier. */ - tree g; - { - /* Parms are to have DECL_CHAIN tsubsted, which would be skipped - if cp_unevaluated_operand. */ - cp_evaluated ev; - g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain, + tree g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain, /*use_spec_table=*/false); - } if (g == error_mark_node) continue; DECL_NAME (g) = name; @@ -31651,7 +31656,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init, tree outer_targs, /* Be permissive with equivalent alias templates. */ tree u = get_underlying_template (tmpl); auto_diagnostic_group d; - diagnostic_t dk = (u == tmpl) ? DK_ERROR : DK_PEDWARN; + const enum diagnostics::kind dk = ((u == tmpl) + ? diagnostics::kind::error + : diagnostics::kind::pedwarn); bool complained = emit_diagnostic (dk, input_location, 0, "alias template deduction only available " |