diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp index 7a0b6252064d..52e9e9bc87ef 100644 --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -241,6 +241,10 @@ bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) { DeclContext *DC = computeDeclContext(SS, true); if (TagDecl *Tag = dyn_cast(DC)) { + // If this is a dependent type, then we consider it complete. + if (Tag->isDependentContext()) + return false; + // If we're currently defining this type, then lookup into the // type is okay: don't complain that it isn't complete yet. const TagType *TagT = Context.getTypeDeclType(Tag)->getAs(); diff --git a/clang/test/SemaTemplate/typename-specifier-4.cpp b/clang/test/SemaTemplate/typename-specifier-4.cpp index 7fd88f130fa6..9c757c5ad0fd 100644 --- a/clang/test/SemaTemplate/typename-specifier-4.cpp +++ b/clang/test/SemaTemplate/typename-specifier-4.cpp @@ -68,3 +68,15 @@ struct X0 { void f2(typename X0::Inner::type); // expected-note{{here}} void f2(typename X0::template Inner::type); // expected-error{{redecl}} }; + +namespace PR6236 { + template struct S { }; + + template struct S { + template struct K { }; + + void f() { + typedef typename S::template K Foo; + } + }; +}