[clang] e902ffe - [Sema] Fix the assertion in Sema::ActOnDependentMemberExpr
Yuanfang Chen via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 4 13:08:26 PST 2022
Author: Yuanfang Chen
Date: 2022-01-04T13:08:12-08:00
New Revision: e902ffe6d7560f708b76edaa53d75edcb5d49a3f
URL: https://github.com/llvm/llvm-project/commit/e902ffe6d7560f708b76edaa53d75edcb5d49a3f
DIFF: https://github.com/llvm/llvm-project/commit/e902ffe6d7560f708b76edaa53d75edcb5d49a3f.diff
LOG: [Sema] Fix the assertion in Sema::ActOnDependentMemberExpr
617007240cbfb97c 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
Added:
Modified:
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp
index 83006f9d804ab..f67ef030feb70 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -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.
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 1a24c66805690..af121a8b75d51 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -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
More information about the cfe-commits
mailing list