+2019-08-22 Jason Merrill <jason@redhat.com>
+
+ * decl2.c (decl_dependent_p): New.
+ (mark_used): Check it instead of just processing_template_decl.
+
2019-08-22 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
}
}
+/* True if DECL or its enclosing scope have unbound template parameters. */
+
+bool
+decl_dependent_p (tree decl)
+{
+ if (DECL_FUNCTION_SCOPE_P (decl)
+ || TREE_CODE (decl) == CONST_DECL
+ || TREE_CODE (decl) == USING_DECL
+ || TREE_CODE (decl) == FIELD_DECL)
+ decl = CP_DECL_CONTEXT (decl);
+ if (tree tinfo = get_template_info (decl))
+ if (any_dependent_template_arguments_p (TI_ARGS (tinfo)))
+ return true;
+ if (LAMBDA_FUNCTION_P (decl)
+ && dependent_type_p (DECL_CONTEXT (decl)))
+ return true;
+ return false;
+}
+
/* Mark DECL (either a _DECL or a BASELINK) as "used" in the program.
If DECL is a specialization or implicitly declared class member,
generate the actual definition. Return false if something goes
decl = OVL_FIRST (decl);
}
+ if (!DECL_P (decl))
+ return true;
+
/* Set TREE_USED for the benefit of -Wunused. */
TREE_USED (decl) = 1;
/* And for structured bindings also the underlying decl. */
|| DECL_LANG_SPECIFIC (decl) == NULL
|| DECL_THUNK_P (decl))
{
- if (!processing_template_decl
+ if (!decl_dependent_p (decl)
&& !require_deduced_type (decl, complain))
return false;
return true;