Author: Richard Smith Date: 2020-09-16T18:11:18-07:00 New Revision: 7337f296194483e0959ff980049e2835e226f396
URL: https://github.com/llvm/llvm-project/commit/7337f296194483e0959ff980049e2835e226f396 DIFF: https://github.com/llvm/llvm-project/commit/7337f296194483e0959ff980049e2835e226f396.diff LOG: PR47555: Inheriting constructors are implicitly definable. Don't forget to define them if they're constexpr and used inside a template; we might try to evaluate a call to them before the template is instantiated. Added: Modified: clang/lib/Sema/SemaExpr.cpp clang/test/SemaCXX/cxx11-inheriting-ctors.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 9a4b3e31e850..c82febdbf3a7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16582,8 +16582,13 @@ static OdrUseContext isOdrUseContext(Sema &SemaRef) { } static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func) { - return Func->isConstexpr() && - (Func->isImplicitlyInstantiable() || !Func->isUserProvided()); + if (!Func->isConstexpr()) + return false; + + if (Func->isImplicitlyInstantiable() || !Func->isUserProvided()) + return true; + auto *CCD = dyn_cast<CXXConstructorDecl>(Func); + return CCD && CCD->getInheritedConstructor(); } /// Mark a function referenced, and check whether it is odr-used diff --git a/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp b/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp index 7d6f4f09f09c..5be428401fa0 100644 --- a/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp +++ b/clang/test/SemaCXX/cxx11-inheriting-ctors.cpp @@ -133,3 +133,12 @@ namespace implicit_member_srcloc { S0<int> s0; } } + +namespace PR47555 { + struct A { constexpr A(int) {} }; + struct B : A { using A::A; }; + template<typename> void f() { + constexpr B b = 0; + }; + template void f<int>(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits