Author: rsmith Date: Thu Oct 3 11:24:40 2019 New Revision: 373643 URL: http://llvm.org/viewvc/llvm-project?rev=373643&view=rev Log: PR43547: substitute into the type of a non-type template parameter if it's instantiation-dependent, even if it's not dependent.
There might be a SFINAE check in the parameter type. Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=373643&r1=373642&r2=373643&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Oct 3 11:24:40 2019 @@ -4922,9 +4922,7 @@ bool Sema::CheckTemplateArgument(NamedDe if (NTTP->isParameterPack() && NTTP->isExpandedParameterPack()) NTTPType = NTTP->getExpansionType(ArgumentPackIndex); - // FIXME: Do we need to substitute into parameters here if they're - // instantiation-dependent but not dependent? - if (NTTPType->isDependentType() && + if (NTTPType->isInstantiationDependentType() && !isa<TemplateTemplateParmDecl>(Template) && !Template->getDeclContext()->isDependentContext()) { // Do substitution on the type of the non-type template parameter. Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=373643&r1=373642&r2=373643&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original) +++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Thu Oct 3 11:24:40 2019 @@ -482,3 +482,15 @@ namespace dependent_backreference { template<short S> void a() { X<short, S, &arr> x; } template<short S> void b() { X<int, S, &arr> x; } // expected-note {{substituting}} } + +namespace instantiation_dependent { + template<typename T, __typeof(sizeof(T))> void f(int); + template<typename T, __typeof(sizeof(0))> int &f(...); + int &rf = f<struct incomplete, 0>(0); + + // FIXME: This fails because we mishandle instantiation-dependent array bounds :( + int arr[sizeof(sizeof(int))]; + template<typename T, int (*)[sizeof(sizeof(T))]> void g(int); + template<typename T, int (*)[sizeof(sizeof(int))]> int &g(...); + int &rg = g<struct incomplete, &arr>(0); // expected-error {{cannot bind}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits