[PATCH] D103595: [clang] Correct MarkFunctionReferenced for local class
Fütő Gergely via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 3 03:10:52 PDT 2021
futogergely updated this revision to Diff 349508.
futogergely added a comment.
clang-format
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103595/new/
https://reviews.llvm.org/D103595
Files:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaTemplate/instantiate-local-class.cpp
Index: clang/test/SemaTemplate/instantiate-local-class.cpp
===================================================================
--- clang/test/SemaTemplate/instantiate-local-class.cpp
+++ clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -504,3 +504,24 @@
}
template void f<int>();
}
+
+namespace PR48839 {
+template <typename T>
+void construct() {
+ T(0);
+}
+
+template <typename T>
+void tester() {
+ struct d {
+ void test() {
+ construct<d>();
+ }
+ constexpr d(T b) : a(b) {}
+
+ T a;
+ };
+}
+
+void g() { tester<int>(); }
+} // namespace PR48839
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -17057,11 +17057,12 @@
PointOfInstantiation = Loc;
}
+ const bool isLocalClass =
+ isa<CXXRecordDecl>(Func->getDeclContext()) &&
+ cast<CXXRecordDecl>(Func->getDeclContext())->isLocalClass();
if (FirstInstantiation || TSK != TSK_ImplicitInstantiation ||
- Func->isConstexpr()) {
- if (isa<CXXRecordDecl>(Func->getDeclContext()) &&
- cast<CXXRecordDecl>(Func->getDeclContext())->isLocalClass() &&
- CodeSynthesisContexts.size())
+ (!isLocalClass && Func->isConstexpr())) {
+ if (isLocalClass && CodeSynthesisContexts.size())
PendingLocalImplicitInstantiations.push_back(
std::make_pair(Func, PointOfInstantiation));
else if (Func->isConstexpr())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103595.349508.patch
Type: text/x-patch
Size: 1568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/96f19e50/attachment.bin>
More information about the cfe-commits
mailing list