[clang] [Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (PR #86526)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 13:16:53 PDT 2024


================
@@ -1473,7 +1475,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
   D.getMutableDeclSpec().abort();
 
   if (BodyKind != Sema::FnBodyKind::Other) {
-    Actions.SetFunctionBodyKind(Res, KWLoc, BodyKind);
+    Actions.SetFunctionBodyKind(Res, KWLoc, BodyKind, DeletedMessage);
----------------
Sirraide wrote:

So after looking into this a bit, I don’t think we want to do that because `Res` is not a `FunctionDecl*` here, it’s a `Decl*`. Specifically, it could also be a template, which means we’d need to first dig out the actual function using `Sema::AdjustDeclIfTemplate`; the same is also true in at least one other place. `SetFunctionBodyKind` calls `SetDeclDeleted`, which already takes care of all of that, so I think it’d make more sense to put that there (however, a `setDeletedMessage()` on `FunctionDecl` is still useful, and I’ll still be using that in other places).

https://github.com/llvm/llvm-project/pull/86526


More information about the cfe-commits mailing list