llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) <details> <summary>Changes</summary> Fixes #<!-- -->112677 --- Full diff: https://github.com/llvm/llvm-project/pull/112860.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2-1) - (modified) clang/lib/AST/Decl.cpp (+13) - (modified) clang/test/SemaCXX/cxx2b-consteval-propagate.cpp (+21) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a65bd6f382901b..8846ee59a6e241 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -418,7 +418,7 @@ Improvements to Clang's diagnostics - The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``, instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being suboptimal in some way the error fails to mention (#GH111550). - + - Clang now emits a ``-Wdepredcated-literal-operator`` diagnostic, even if the name was a reserved name, which we improperly allowed to suppress the diagnostic. @@ -537,6 +537,7 @@ Bug Fixes to C++ Support certain situations. (#GH47400), (#GH90896) - Fix erroneous templated array size calculation leading to crashes in generated code. (#GH41441) - During the lookup for a base class name, non-type names are ignored. (#GH16855) +- Fix immediate escalation not propagating through inherited constructors. (#GH112677) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 8321cee0e0bc94..5314d01ed4fb6c 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3284,6 +3284,13 @@ bool FunctionDecl::isImmediateEscalating() const { // consteval specifier, if (isDefaulted() && !isConsteval()) return true; + + if (auto *CD = dyn_cast<CXXConstructorDecl>(this); + CD && CD->isInheritingConstructor()) + return CD->getInheritedConstructor() + .getConstructor() + ->isImmediateEscalating(); + // - a function that results from the instantiation of a templated entity // defined with the constexpr specifier. TemplatedKind TK = getTemplatedKind(); @@ -3304,6 +3311,12 @@ bool FunctionDecl::isImmediateFunction() const { if (isImmediateEscalating() && BodyContainsImmediateEscalatingExpressions()) return true; + if (auto *CD = dyn_cast<CXXConstructorDecl>(this); + CD && CD->isInheritingConstructor()) + return CD->getInheritedConstructor() + .getConstructor() + ->isImmediateFunction(); + if (const auto *MD = dyn_cast<CXXMethodDecl>(this); MD && MD->isLambdaStaticInvoker()) return MD->getParent()->getLambdaCallOperator()->isImmediateFunction(); diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp index 378414f1361729..187a4958a2ee62 100644 --- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -496,3 +496,24 @@ struct Y { template void g<Y>(); } + +namespace GH112677 { + +class ConstEval { + public: + consteval ConstEval(int); // expected-note {{declared here}} +}; + +struct B { + ConstEval val; + template <class Anything = int> constexpr + B(int arg) : val(arg) {} // expected-note {{undefined constructor 'ConstEval'}} +}; +struct C : B { + using B::B; // expected-note {{in call to 'B<int>(0)'}} +}; + +C c(0); // expected-note{{in implicit initialization for inherited constructor of 'C'}} +// expected-error@-1 {{call to immediate function 'GH112677::C::B' is not a constant expression}} + +} `````````` </details> https://github.com/llvm/llvm-project/pull/112860 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits