[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 01:33:32 PDT 2021
futogergely updated this revision to Diff 349480.
futogergely added a comment.
formatting in instantiate-local-class.cpp
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>(); }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -17057,10 +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() &&
+ (!isLocalClass && Func->isConstexpr())) {
+ if (isLocalClass &&
CodeSynthesisContexts.size())
PendingLocalImplicitInstantiations.push_back(
std::make_pair(Func, PointOfInstantiation));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103595.349480.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210603/b0a82535/attachment-0001.bin>
More information about the cfe-commits
mailing list