[Sema] Fix the assertion in Sema::ActOnDependentMemberExpr

617007240c introduced the use of ActOnDependentMemberExpr with
variable template specialization. The assertion inside
ActOnDependentMemberExpr should be adjusted accordingly.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47211

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D113146
This commit is contained in:
Yuanfang Chen 2022-01-04 12:11:33 -08:00
parent dd72ae3dcc
commit e902ffe6d7
2 changed files with 18 additions and 3 deletions

View File

@ -504,9 +504,12 @@ Sema::ActOnDependentMemberExpr(Expr *BaseExpr, QualType BaseType,
}
}
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.

View File

@ -394,6 +394,18 @@ namespace dependent_static_var_template {
template<int = 0> static int n; // expected-note {{here}}
}
int &t = B::template n; // expected-error {{use of variable template 'n' requires template arguments}}
struct C {
template <class T> static T G;
};
template<class T> T C::G = T(6);
template <class T> T F() {
C c;
return c.G<T>;
}
int cf() { return F<int>(); }
}
#ifndef PRECXX11