aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSirraide <aeternalmail@gmail.com>2024-04-14 12:30:01 +0200
committerGitHub <noreply@github.com>2024-04-14 12:30:01 +0200
commitef164cee90477e294ff692209b4cf97a0e1958ed (patch)
tree3c287ecad68abfcc42764475fb6906c1da856afc /clang/lib/Sema/SemaDecl.cpp
parented06b847d4e77d0b81fa6b095366bb070db57846 (diff)
downloadllvm-ef164cee90477e294ff692209b4cf97a0e1958ed.zip
llvm-ef164cee90477e294ff692209b4cf97a0e1958ed.tar.gz
llvm-ef164cee90477e294ff692209b4cf97a0e1958ed.tar.bz2
[Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (#86526)
This implements support for the `= delete("message")` syntax that was only just added to C++26 ([P2573R2](https://isocpp.org/files/papers/P2573R2.html#proposal-scope)).
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 17032d1..8b3b9d0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16083,7 +16083,17 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
// This is meant to pop the context added in ActOnStartOfFunctionDef().
ExitFunctionBodyRAII ExitRAII(*this, isLambdaCallOperator(FD));
if (FD) {
- FD->setBody(Body);
+ // If this is called by Parser::ParseFunctionDefinition() after marking
+ // the declaration as deleted, and if the deleted-function-body contains
+ // a message (C++26), then a DefaultedOrDeletedInfo will have already been
+ // added to store that message; do not overwrite it in that case.
+ //
+ // Since this would always set the body to 'nullptr' in that case anyway,
+ // which is already done when the function decl is initially created,
+ // always skipping this irrespective of whether there is a delete message
+ // should not be a problem.
+ if (!FD->isDeletedAsWritten())
+ FD->setBody(Body);
FD->setWillHaveBody(false);
CheckImmediateEscalatingFunctionDefinition(FD, FSI);