Commit 11399477 by Jason Merrill Committed by Jason Merrill

Various small fixes.

	* lambda.c (build_lambda_object): Check for error_mark_node.
	* pt.c (make_pack_expansion): Set PACK_EXPANSION_LOCAL_P on the type
	pack as well.
	(tsubst_decl) [FUNCTION_DECL]: Set DECL_CONTEXT on the parameters.
	(tsubst) [TEMPLATE_PARM_INDEX]: Check for error_mark_node.

From-SVN: r251428
parent 1a9de5b6
2017-08-23 Jason Merrill <jason@redhat.com>
* lambda.c (build_lambda_object): Check for error_mark_node.
* pt.c (make_pack_expansion): Set PACK_EXPANSION_LOCAL_P on the type
pack as well.
(tsubst_decl) [FUNCTION_DECL]: Set DECL_CONTEXT on the parameters.
(tsubst) [TEMPLATE_PARM_INDEX]: Check for error_mark_node.
2017-08-29 Jason Merrill <jason@redhat.com> 2017-08-29 Jason Merrill <jason@redhat.com>
PR c++/80767 - unnecessary instantiation of generic lambda PR c++/80767 - unnecessary instantiation of generic lambda
......
...@@ -1458,7 +1458,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t, ...@@ -1458,7 +1458,8 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
{ {
if (!ctx->quiet) if (!ctx->quiet)
{ {
error_at (loc, "call to non-constexpr function %qD", fun); if (!lambda_static_thunk_p (fun))
error_at (loc, "call to non-constexpr function %qD", fun);
explain_invalid_constexpr_fn (fun); explain_invalid_constexpr_fn (fun);
} }
*non_constant_p = true; *non_constant_p = true;
......
...@@ -59,7 +59,7 @@ build_lambda_object (tree lambda_expr) ...@@ -59,7 +59,7 @@ build_lambda_object (tree lambda_expr)
tree node, expr, type; tree node, expr, type;
location_t saved_loc; location_t saved_loc;
if (processing_template_decl) if (processing_template_decl || lambda_expr == error_mark_node)
return lambda_expr; return lambda_expr;
/* Make sure any error messages refer to the lambda-introducer. */ /* Make sure any error messages refer to the lambda-introducer. */
......
...@@ -3773,6 +3773,7 @@ make_pack_expansion (tree arg) ...@@ -3773,6 +3773,7 @@ make_pack_expansion (tree arg)
purpose = cxx_make_type (TYPE_PACK_EXPANSION); purpose = cxx_make_type (TYPE_PACK_EXPANSION);
SET_PACK_EXPANSION_PATTERN (purpose, TREE_PURPOSE (arg)); SET_PACK_EXPANSION_PATTERN (purpose, TREE_PURPOSE (arg));
PACK_EXPANSION_PARAMETER_PACKS (purpose) = parameter_packs; PACK_EXPANSION_PARAMETER_PACKS (purpose) = parameter_packs;
PACK_EXPANSION_LOCAL_P (purpose) = at_function_scope_p ();
/* Just use structural equality for these TYPE_PACK_EXPANSIONS; /* Just use structural equality for these TYPE_PACK_EXPANSIONS;
they will rarely be compared to anything. */ they will rarely be compared to anything. */
...@@ -9535,6 +9536,7 @@ static inline bool ...@@ -9535,6 +9536,7 @@ static inline bool
neglectable_inst_p (tree d) neglectable_inst_p (tree d)
{ {
return (DECL_P (d) return (DECL_P (d)
&& !undeduced_auto_decl (d)
&& !(TREE_CODE (d) == FUNCTION_DECL ? DECL_DECLARED_CONSTEXPR_P (d) && !(TREE_CODE (d) == FUNCTION_DECL ? DECL_DECLARED_CONSTEXPR_P (d)
: decl_maybe_constant_var_p (d))); : decl_maybe_constant_var_p (d)));
} }
...@@ -12413,6 +12415,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -12413,6 +12415,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
DECL_ARGUMENTS (r) = tsubst (DECL_ARGUMENTS (t), args, DECL_ARGUMENTS (r) = tsubst (DECL_ARGUMENTS (t), args,
complain, t); complain, t);
for (tree parm = DECL_ARGUMENTS (r); parm; parm = DECL_CHAIN (parm))
DECL_CONTEXT (parm) = r;
DECL_RESULT (r) = NULL_TREE; DECL_RESULT (r) = NULL_TREE;
TREE_STATIC (r) = 0; TREE_STATIC (r) = 0;
...@@ -13786,6 +13790,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) ...@@ -13786,6 +13790,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
couldn't do it earlier because it might be an auto parameter, couldn't do it earlier because it might be an auto parameter,
and we wouldn't need to if we had an argument. */ and we wouldn't need to if we had an argument. */
type = tsubst (type, args, complain, in_decl); type = tsubst (type, args, complain, in_decl);
if (type == error_mark_node)
return error_mark_node;
r = reduce_template_parm_level (t, type, levels, args, complain); r = reduce_template_parm_level (t, type, levels, args, complain);
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment