Index: lib/AST/ASTDiagnostic.cpp =================================================================== --- lib/AST/ASTDiagnostic.cpp +++ lib/AST/ASTDiagnostic.cpp @@ -65,11 +65,21 @@ continue; } - // Don't desugar template specializations, unless it's an alias template. + // Don't desugar template specializations, unless it's an alias template + // or one of the template arguments is a decltype. if (const TemplateSpecializationType *TST - = dyn_cast(Ty)) - if (!TST->isTypeAlias()) + = dyn_cast(Ty)) { + bool AnyDecltypeArgs = false; + for (auto Arg : *TST) + if (Arg.getKind() == TemplateArgument::Type && + Arg.getAsType()->getAs()) { + AnyDecltypeArgs = true; + break; + } + + if (!AnyDecltypeArgs && !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,9 @@ void test() { helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}} } + +// PR10405 +template +class Temp {}; + +int t = Temp(); // expected-error{{no viable conversion from 'Temp' (aka 'Temp') to 'int'}}