Index: lib/Sema/SemaTemplate.cpp =================================================================== --- lib/Sema/SemaTemplate.cpp +++ lib/Sema/SemaTemplate.cpp @@ -4804,7 +4804,12 @@ // template. TemplateArgumentListInfo NewArgs = TemplateArgs; - TemplateParameterList *Params = Template->getTemplateParameters(); + // Make sure we get the template parameter list from the most + // recentdeclaration, since that is the only one that has is guaranteed to + // have all the default template argument information. + TemplateParameterList *Params = + cast(Template->getMostRecentDecl()) + ->getTemplateParameters(); SourceLocation RAngleLoc = NewArgs.getRAngleLoc(); Index: test/SemaCXX/template-default-param-through-using.cpp =================================================================== --- test/SemaCXX/template-default-param-through-using.cpp +++ test/SemaCXX/template-default-param-through-using.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics +namespace llvm { + template struct StringSet; + template struct Int; + template class Outer> + struct TemplTempl; +} + +namespace lld { + using llvm::StringSet; + using llvm::Int; + using llvm::TemplTempl; +}; + +namespace llvm { + template struct StringSet; +} + +template struct Temp{}; + +namespace llvm { + template struct StringSet{}; + template struct Int{}; + template class Outer = Temp> + struct TemplTempl{}; +}; + +namespace lld { + StringSet<> s; + Int<> i; + TemplTempl tt; +}