diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -6934,8 +6934,6 @@ Expr *Inits[1] = {DeductionArg}; ParamType = DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind, Inits); - if (ParamType.isNull()) - return ExprError(); } else { TemplateDeductionInfo Info(DeductionArg->getExprLoc(), Param->getDepth() + 1); @@ -6958,6 +6956,8 @@ return ExprError(); } } + if (ParamType.isNull()) + return ExprError(); // CheckNonTypeTemplateParameterType will produce a diagnostic if there's // an error. The error message normally references the parameter // declaration, but here we'll pass the argument location because that's diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp @@ -558,3 +558,24 @@ X<1, 1u>::type y; // expected-error {{no type named 'type' in 'TypeSuffix::X<1, 1U>'}} X<1, 1>::type z; // expected-error {{no type named 'type' in 'TypeSuffix::X<1, 1>'}} } + +namespace no_crash { +template +class Base { +public: + template class EntryPointSpec {}; + template + using EntryPoint = EntryPointSpec; +}; + +class Derived : Base{ + template class Spec {}; + + void Invalid(Undefined) const; // expected-error {{unknown type name 'Undefined'}} + void crash() { + return Spec{ + EntryPoint<&Invalid>() + }; + } +}; +} // no_crash