diff options
| author | Corentin Jabot <corentinjabot@gmail.com> | 2025-10-14 16:39:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-14 16:39:45 +0200 |
| commit | eb76690ea17d7c03b5893a68e306760a79743dac (patch) | |
| tree | 9e0a2dfe05a7bbccc185a9ac359f04867498cbc7 /clang/lib | |
| parent | e8ee944a4f2e9f70c8b49452878c2ebe038a8da4 (diff) | |
| download | llvm-eb76690ea17d7c03b5893a68e306760a79743dac.zip llvm-eb76690ea17d7c03b5893a68e306760a79743dac.tar.gz llvm-eb76690ea17d7c03b5893a68e306760a79743dac.tar.bz2 | |
[Clang] Destructors should not be immediate-escalating (#163390)
We allow destructors to become immediate functions, which makes little
sense as the standard disallow
consteval destructors
Related CWG issue https://github.com/cplusplus/CWG/issues/780
Fixes #109096
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index c734155..69cbf6e 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3316,6 +3316,10 @@ bool FunctionDecl::isImmediateEscalating() const { CD && CD->isInheritingConstructor()) return CD->getInheritedConstructor().getConstructor(); + // Destructors are not immediate escalating. + if (isa<CXXDestructorDecl>(this)) + return false; + // - a function that results from the instantiation of a templated entity // defined with the constexpr specifier. TemplatedKind TK = getTemplatedKind(); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 85e3d20..73fd33a 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -5727,7 +5727,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, Function->setDeclarationNameLoc(NameLocPointsToPattern()); EnterExpressionEvaluationContextForFunction EvalContext( - *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated); + *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Function); Qualifiers ThisTypeQuals; CXXRecordDecl *ThisContext = nullptr; |
