diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 870f992c6d71..cab63d060c9e 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -4513,19 +4513,32 @@ TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, // Copy information relevant to the template specialization. TemplateSpecializationTypeLoc NamedTL - = TLB.push(NamedT); + = TLB.push(NamedT); NamedTL.setLAngleLoc(TL.getLAngleLoc()); NamedTL.setRAngleLoc(TL.getRAngleLoc()); - for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) - NamedTL.setArgLocInfo(I, TL.getArgLocInfo(I)); + for (unsigned I = 0, E = NamedTL.getNumArgs(); I != E; ++I) + NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); // Copy information relevant to the elaborated type. ElaboratedTypeLoc NewTL = TLB.push(Result); NewTL.setKeywordLoc(TL.getKeywordLoc()); NewTL.setQualifierLoc(QualifierLoc); + } else if (isa(Result)) { + DependentTemplateSpecializationTypeLoc SpecTL + = TLB.push(Result); + SpecTL.setQualifierLoc(QualifierLoc); + SpecTL.setLAngleLoc(TL.getLAngleLoc()); + SpecTL.setRAngleLoc(TL.getRAngleLoc()); + SpecTL.setNameLoc(TL.getNameLoc()); + for (unsigned I = 0, E = SpecTL.getNumArgs(); I != E; ++I) + SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); } else { - TypeLoc NewTL(Result, TL.getOpaqueData()); - TLB.pushFullCopy(NewTL); + TemplateSpecializationTypeLoc SpecTL + = TLB.push(Result); + SpecTL.setLAngleLoc(TL.getLAngleLoc()); + SpecTL.setRAngleLoc(TL.getRAngleLoc()); + for (unsigned I = 0, E = SpecTL.getNumArgs(); I != E; ++I) + SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); } return Result; } diff --git a/clang/test/SemaTemplate/instantiate-member-template.cpp b/clang/test/SemaTemplate/instantiate-member-template.cpp index e2f72756189c..4c74f5fb938b 100644 --- a/clang/test/SemaTemplate/instantiate-member-template.cpp +++ b/clang/test/SemaTemplate/instantiate-member-template.cpp @@ -215,3 +215,47 @@ namespace PR8489 { c.F(); // expected-error{{no matching member function}} } } + +namespace rdar8986308 { + template struct __static_assert_test; + template <> struct __static_assert_test {}; + template struct __static_assert_check {}; + + namespace std { + + template + struct __has_rebind + { + private: + struct __two {char _; char __;}; + template static __two __test(...); + template static char __test(typename _Xp::template rebind<_Up>* = 0); + public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; + }; + + } + + template struct B1 {}; + + template + struct B + { + template struct rebind {typedef B1 other;}; + }; + + template struct D1 {}; + + template + struct D + { + template struct rebind {typedef D1 other;}; + }; + + int main() + { + typedef __static_assert_check, double>::value))>)> __t64; + typedef __static_assert_check, double>::value))>)> __t64; + } + +}