Commit 1a5bac38 by Nathan Sidwell Committed by Nathan Sidwell

cp-tree.h (instantiate_decl): Make defer_ok bool.

	* cp-tree.h (instantiate_decl): Make defer_ok bool.
	* pt.c: Fix instantiate_decl calls to pass true/false not 0/1
	(instantiate_decl): Simplify and reorder state saving and restoration.

From-SVN: r245066
parent 7f357c61
2017-01-31 Nathan Sidwell <nathan@acm.org> 2017-01-31 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (instantiate_decl): Make defer_ok bool.
* pt.c: Fix instantiate_decl calls to pass true/false not 0/1
(instantiate_decl): Simplify and reorder state saving and restoration.
PR c++/79264 PR c++/79264
* lambda.c (maybe_generic_this_capture): Deal with template-id-exprs. * lambda.c (maybe_generic_this_capture): Deal with template-id-exprs.
* semantics.c (finish_member_declaration): Assert class is being * semantics.c (finish_member_declaration): Assert class is being
......
...@@ -6189,7 +6189,7 @@ extern void do_decl_instantiation (tree, tree); ...@@ -6189,7 +6189,7 @@ extern void do_decl_instantiation (tree, tree);
extern void do_type_instantiation (tree, tree, tsubst_flags_t); extern void do_type_instantiation (tree, tree, tsubst_flags_t);
extern bool always_instantiate_p (tree); extern bool always_instantiate_p (tree);
extern void maybe_instantiate_noexcept (tree); extern void maybe_instantiate_noexcept (tree);
extern tree instantiate_decl (tree, int, bool); extern tree instantiate_decl (tree, bool, bool);
extern int comp_template_parms (const_tree, const_tree); extern int comp_template_parms (const_tree, const_tree);
extern bool uses_parameter_packs (tree); extern bool uses_parameter_packs (tree);
extern bool template_parameter_pack_p (const_tree); extern bool template_parameter_pack_p (const_tree);
......
...@@ -10676,7 +10676,7 @@ instantiate_class_template_1 (tree type) ...@@ -10676,7 +10676,7 @@ instantiate_class_template_1 (tree type)
{ {
/* Set function_depth to avoid garbage collection. */ /* Set function_depth to avoid garbage collection. */
++function_depth; ++function_depth;
instantiate_decl (decl, false, false); instantiate_decl (decl, /*defer_ok=*/false, false);
--function_depth; --function_depth;
} }
...@@ -16022,7 +16022,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, ...@@ -16022,7 +16022,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
complete_type (tmp); complete_type (tmp);
for (fn = TYPE_METHODS (tmp); fn; fn = DECL_CHAIN (fn)) for (fn = TYPE_METHODS (tmp); fn; fn = DECL_CHAIN (fn))
if (!DECL_ARTIFICIAL (fn)) if (!DECL_ARTIFICIAL (fn))
instantiate_decl (fn, /*defer_ok*/0, /*expl_inst_class*/false); instantiate_decl (fn, /*defer_ok=*/false,
/*expl_inst_class=*/false);
} }
break; break;
...@@ -21946,7 +21947,7 @@ do_decl_instantiation (tree decl, tree storage) ...@@ -21946,7 +21947,7 @@ do_decl_instantiation (tree decl, tree storage)
check_explicit_instantiation_namespace (result); check_explicit_instantiation_namespace (result);
mark_decl_instantiated (result, extern_p); mark_decl_instantiated (result, extern_p);
if (! extern_p) if (! extern_p)
instantiate_decl (result, /*defer_ok=*/1, instantiate_decl (result, /*defer_ok=*/true,
/*expl_inst_class_mem_p=*/false); /*expl_inst_class_mem_p=*/false);
} }
...@@ -21984,7 +21985,7 @@ instantiate_class_member (tree decl, int extern_p) ...@@ -21984,7 +21985,7 @@ instantiate_class_member (tree decl, int extern_p)
{ {
mark_decl_instantiated (decl, extern_p); mark_decl_instantiated (decl, extern_p);
if (! extern_p) if (! extern_p)
instantiate_decl (decl, /*defer_ok=*/1, instantiate_decl (decl, /*defer_ok=*/true,
/*expl_inst_class_mem_p=*/true); /*expl_inst_class_mem_p=*/true);
} }
...@@ -22405,15 +22406,14 @@ maybe_instantiate_noexcept (tree fn) ...@@ -22405,15 +22406,14 @@ maybe_instantiate_noexcept (tree fn)
} }
/* Produce the definition of D, a _DECL generated from a template. If /* Produce the definition of D, a _DECL generated from a template. If
DEFER_OK is nonzero, then we don't have to actually do the DEFER_OK is true, then we don't have to actually do the
instantiation now; we just have to do it sometime. Normally it is instantiation now; we just have to do it sometime. Normally it is
an error if this is an explicit instantiation but D is undefined. an error if this is an explicit instantiation but D is undefined.
EXPL_INST_CLASS_MEM_P is true iff D is a member of an EXPL_INST_CLASS_MEM_P is true iff D is a member of an explicitly
explicitly instantiated class template. */ instantiated class template. */
tree tree
instantiate_decl (tree d, int defer_ok, instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p)
bool expl_inst_class_mem_p)
{ {
tree tmpl = DECL_TI_TEMPLATE (d); tree tmpl = DECL_TI_TEMPLATE (d);
tree gen_args; tree gen_args;
...@@ -22428,8 +22428,6 @@ instantiate_decl (tree d, int defer_ok, ...@@ -22428,8 +22428,6 @@ instantiate_decl (tree d, int defer_ok,
int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings; int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
bool external_p; bool external_p;
bool deleted_p; bool deleted_p;
tree fn_context;
bool nested = false;
/* This function should only be used to instantiate templates for /* This function should only be used to instantiate templates for
functions and static member variables. */ functions and static member variables. */
...@@ -22444,7 +22442,7 @@ instantiate_decl (tree d, int defer_ok, ...@@ -22444,7 +22442,7 @@ instantiate_decl (tree d, int defer_ok,
if the variable has a constant value the referring expression can if the variable has a constant value the referring expression can
take advantage of that fact. */ take advantage of that fact. */
if (VAR_P (d)) if (VAR_P (d))
defer_ok = 0; defer_ok = false;
/* Don't instantiate cloned functions. Instead, instantiate the /* Don't instantiate cloned functions. Instead, instantiate the
functions they cloned. */ functions they cloned. */
...@@ -22668,6 +22666,8 @@ instantiate_decl (tree d, int defer_ok, ...@@ -22668,6 +22666,8 @@ instantiate_decl (tree d, int defer_ok,
goto out; goto out;
} }
bool nested;
tree fn_context;
fn_context = decl_function_context (d); fn_context = decl_function_context (d);
nested = (current_function_decl != NULL_TREE); nested = (current_function_decl != NULL_TREE);
vec<tree> omp_privatization_save; vec<tree> omp_privatization_save;
...@@ -22854,16 +22854,16 @@ instantiate_decl (tree d, int defer_ok, ...@@ -22854,16 +22854,16 @@ instantiate_decl (tree d, int defer_ok,
else if (nested) else if (nested)
pop_function_context (); pop_function_context ();
out:
input_location = saved_loc;
cp_unevaluated_operand = saved_unevaluated_operand;
c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
pop_deferring_access_checks ();
pop_tinst_level ();
if (nested) if (nested)
restore_omp_privatization_clauses (omp_privatization_save); restore_omp_privatization_clauses (omp_privatization_save);
out:
pop_deferring_access_checks ();
timevar_pop (TV_TEMPLATE_INST); timevar_pop (TV_TEMPLATE_INST);
pop_tinst_level ();
input_location = saved_loc;
cp_unevaluated_operand = saved_unevaluated_operand;
c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;
return d; return d;
} }
...@@ -22919,7 +22919,7 @@ instantiate_pending_templates (int retries) ...@@ -22919,7 +22919,7 @@ instantiate_pending_templates (int retries)
fn = TREE_CHAIN (fn)) fn = TREE_CHAIN (fn))
if (! DECL_ARTIFICIAL (fn)) if (! DECL_ARTIFICIAL (fn))
instantiate_decl (fn, instantiate_decl (fn,
/*defer_ok=*/0, /*defer_ok=*/false,
/*expl_inst_class_mem_p=*/false); /*expl_inst_class_mem_p=*/false);
if (COMPLETE_TYPE_P (instantiation)) if (COMPLETE_TYPE_P (instantiation))
reconsider = 1; reconsider = 1;
...@@ -22934,7 +22934,7 @@ instantiate_pending_templates (int retries) ...@@ -22934,7 +22934,7 @@ instantiate_pending_templates (int retries)
{ {
instantiation instantiation
= instantiate_decl (instantiation, = instantiate_decl (instantiation,
/*defer_ok=*/0, /*defer_ok=*/false,
/*expl_inst_class_mem_p=*/false); /*expl_inst_class_mem_p=*/false);
if (DECL_TEMPLATE_INSTANTIATED (instantiation)) if (DECL_TEMPLATE_INSTANTIATED (instantiation))
reconsider = 1; reconsider = 1;
......
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