On Tue, Jan 19, 2016 at 9:56 AM, Jason Merrill <ja...@redhat.com> wrote: > On 01/18/2016 10:55 PM, Patrick Palka wrote: >> >> mark_used is wrongly diagnosing a use of a TEMPLATE_DECL (e.g. the call >> to f1 in function f3 of auto-fn29.C below) for having an undeduced >> 'auto' return type. This doesn't make sense, because an 'auto' used >> inside a template doesn't get deduced until after the template is >> instantiated. So for a TEMPLATE_DECL we shouldn't diagnose a use of >> undeduced 'auto' here. After instantiation, presumably we will call >> mark_used on the resulting FUNCTION_DECL which will check for undeduced >> auto appropriately. >> @@ -5112,7 +5112,9 @@ mark_used (tree decl, tsubst_flags_t complain) >> || DECL_LANG_SPECIFIC (decl) == NULL >> || DECL_THUNK_P (decl)) >> { >> - if (!processing_template_decl && type_uses_auto (TREE_TYPE (decl))) >> + if (!processing_template_decl >> + && TREE_CODE (decl) != TEMPLATE_DECL >> + && type_uses_auto (TREE_TYPE (decl))) > > > How does a TEMPLATE_DECL get in here? Does it have null DECL_LANG_SPECIFIC?
(In the test case auto-fn29.C,) When instantiating the template function f3,we call tsubst on the CALL_EXPR "f1 (v);". There, ADL is performed on the identifier f1 (which is the CALL_EXPR_FN) which returns the TEMPLATE_DECL f1. Then mark_used is called on this CALL_EXPR_FN, only if it's a decl. If in the test case the call to "f1 (v);" is replaced with "Ape::f1 (v);" then the CALL_EXPR_FN is then an OVERLOAD (to the TEMPLATE_DECL f1), i.e. not a decl, so we don't call mark_used on it in tsubst. The DECL_LANG_SPECIFIC of this decl is not null. > > I'd think mark_used of a TEMPLATE_DECL should return after setting > TREE_USED, there's nothing else to do with it. Consider it changed. > > Jason > >