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())
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())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits