[PATCH] D113146: Fix the assertion in Sema::ActOnDependentMemberExpr
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 3 14:34:02 PDT 2021
ychen created this revision.
ychen added a reviewer: rsmith.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
617007240cbfb97c <https://reviews.llvm.org/rG617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9> introduced the use of ActOnDependentMemberExpr with
variable template specialization. The assertion inside
ActOnDependentMemberExpr should be adjusted accordingly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D113146
Files:
clang/lib/Sema/SemaExprMember.cpp
clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
Index: clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
===================================================================
--- clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -394,6 +394,18 @@
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
Index: clang/lib/Sema/SemaExprMember.cpp
===================================================================
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -504,8 +504,11 @@
}
}
- assert(BaseType->isDependentType() ||
- NameInfo.getName().isDependentName() ||
+ assert(BaseType->isDependentType() || NameInfo.getName().isDependentName() ||
+ llvm::any_of(TemplateArgs->arguments(),
+ [](const TemplateArgumentLoc &Arg) {
+ return Arg.getArgument().isDependent();
+ }) ||
isDependentScopeSpecifier(SS));
// Get the type being accessed in BaseType. If this is an arrow, the BaseExpr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113146.384588.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211103/3cf088ae/attachment-0001.bin>
More information about the cfe-commits
mailing list