Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -4597,11 +4597,15 @@ case TemplateArgument::Expression: { TemplateArgument Result; + unsigned CurSFINAEErrors = NumSFINAEErrors; ExprResult Res = CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(), Result, CTAK); if (Res.isInvalid()) return true; + // If the current template argument causes an error, give up now. + if (CurSFINAEErrors < NumSFINAEErrors) + return true; // If the resulting expression is new, then use it in place of the // old expression in the template argument. Index: test/SemaTemplate/temp_arg_nontype_cxx11.cpp =================================================================== --- test/SemaTemplate/temp_arg_nontype_cxx11.cpp +++ test/SemaTemplate/temp_arg_nontype_cxx11.cpp @@ -36,3 +36,15 @@ struct Y { constexpr operator int() const { return 0; } }; template struct A {}; // expected-error {{cannot be deduced}} expected-note {{'y'}} } + +namespace ReportCorrectParam { +template +void TempFunc() {} + +void Useage() { + //expected-error@+2 {{no matching function}} + //expected-note@-4 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'b'}} + TempFunc<1, -1, 1>(); +} +} +