Index: lib/AST/ASTDiagnostic.cpp =================================================================== --- lib/AST/ASTDiagnostic.cpp +++ lib/AST/ASTDiagnostic.cpp @@ -65,11 +65,20 @@ continue; } - // Don't desugar template specializations, unless it's an alias template. + // Don't desugar template specializations, unless it's an alias template + // or decltype appears anywhere in the type. if (const TemplateSpecializationType *TST - = dyn_cast(Ty)) - if (!TST->isTypeAlias()) + = dyn_cast(Ty)) { + for (auto Arg : *TST) { + if (Arg.getKind() == TemplateArgument::Type) + Desugar(Context, Arg.getAsType(), ShouldAKA); + if (ShouldAKA) + break; + } + + if (!ShouldAKA && !TST->isTypeAlias()) break; + } // Don't desugar magic Objective-C types. if (QualType(Ty,0) == Context.getObjCIdType() || Index: test/Misc/diag-aka-types.cpp =================================================================== --- test/Misc/diag-aka-types.cpp +++ test/Misc/diag-aka-types.cpp @@ -45,3 +45,12 @@ void test() { helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}} } + +// PR10405 +template +class Temp {}; + +int t1 = Temp(); // expected-error{{no viable conversion from 'Temp' (aka 'Temp') to 'int'}} +int t2 = Temp>(); // expected-error{{no viable conversion from 'Temp >' (aka 'Temp >') to 'int'}} +int t3 = Temp<__typeof(1 + 2)>(); // expected-error{{no viable conversion from 'Temp' (aka 'Temp') to 'int'}} +int t4 = Temp>(); // expected-error{{no viable conversion from 'Temp >' (aka 'Temp >') to 'int'}}