diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -504,9 +504,12 @@ } } - assert(BaseType->isDependentType() || - NameInfo.getName().isDependentName() || - isDependentScopeSpecifier(SS)); + assert(BaseType->isDependentType() || NameInfo.getName().isDependentName() || + isDependentScopeSpecifier(SS) || + (TemplateArgs && llvm::any_of(TemplateArgs->arguments(), + [](const TemplateArgumentLoc &Arg) { + return Arg.getArgument().isDependent(); + }))); // Get the type being accessed in BaseType. If this is an arrow, the BaseExpr // must have pointer type, and the accessed type is the pointee. diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp --- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp @@ -394,6 +394,18 @@ template static int n; // expected-note {{here}} } int &t = B::template n; // expected-error {{use of variable template 'n' requires template arguments}} + + struct C { + template static T G; + }; + template T C::G = T(6); + + template T F() { + C c; + return c.G; + } + + int cf() { return F(); } } #ifndef PRECXX11