bool uneval = (cp_unevaluated_operand != 0
|| processing_template_decl
- || in_template_function ());
+ || in_template_context);
/* For a non-pointer simple base reference, express it as a COMPONENT_REF
without taking its address (and so causing lambda capture, 91933). */
/* processing_template_decl can be false in a template if we're in
instantiate_non_dependent_expr, but we still want to suppress
this check. */
- if (in_template_function ())
+ if (in_template_context)
{
/* In a template we only care about the type of the result. */
if (nonnull)
#define current_template_parms scope_chain->template_parms
#define current_template_depth \
(current_template_parms ? TMPL_PARMS_DEPTH (current_template_parms) : 0)
+#define in_template_context (current_template_parms != NULL_TREE)
#define processing_template_decl scope_chain->x_processing_template_decl
#define processing_specialization scope_chain->x_processing_specialization
extern bool uses_template_parms (tree);
extern bool uses_template_parms_level (tree, int);
extern bool uses_outer_template_parms_in_constraints (tree);
-extern bool in_template_function (void);
extern bool need_generic_capture (void);
extern tree instantiate_class_template (tree);
extern tree instantiate_template (tree, tree, tsubst_flags_t);
tree domain = NULL_TREE;
tree init = NULL_TREE;
- if (!(type_dep && in_template_function ()))
+ if (!(type_dep && current_function_decl && in_template_context))
{
const char *name = NULL;
bool release_name = false;
&& DECL_OMP_DECLARE_REDUCTION_P (decl)))
maybe_instantiate_decl (decl);
- if (processing_template_decl || in_template_function ())
+ if (processing_template_decl || in_template_context)
return true;
/* Check this too in case we're within instantiate_non_dependent_expr. */
return instantiation_dependent_expression_p (t);
}
-/* Returns true iff we're processing an incompletely instantiated function
- template. Useful instead of processing_template_decl because the latter
- is set to 0 during instantiate_non_dependent_expr. */
-
-bool
-in_template_function (void)
-{
- /* Inspect the less volatile cfun->decl instead of current_function_decl;
- the latter might get set for e.g. access checking during satisfaction. */
- tree fn = cfun ? cfun->decl : NULL_TREE;
- bool ret;
- ++processing_template_decl;
- ret = (fn && DECL_LANG_SPECIFIC (fn)
- && DECL_TEMPLATE_INFO (fn)
- && any_dependent_template_arguments_p (DECL_TI_ARGS (fn)));
- --processing_template_decl;
- return ret;
-}
-
/* Returns true if T depends on any template parameter with level LEVEL. */
bool
}
tree cs = current_scope ();
- if (current_template_parms
+ if (in_template_context
&& (CLASS_TYPE_P (cs) || TREE_CODE (cs) == FUNCTION_DECL))
if (tree template_info = get_template_info (cs))
{
// PR c++/89973
// { dg-do compile { target c++14 } }
-constexpr int a(); // { dg-warning "used but never defined" }
+constexpr int a();
template <typename>
constexpr void *b = a(); // { dg-error "invalid conversion" }