[PATCH] D122981: [Clang] CWG 1394: Incomplete types as parameters of deleted functions

Chuanqi Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 22:45:19 PDT 2022

ChuanqiXu added inline comments.

Comment at: clang/include/clang/Sema/Sema.h:2899-2909
+    /// C++ [dcl.fct.def.general]p1
+    /// function-body:
+    ///   = delete ;
+    ///   = default ;
+    Delete,
+    Default,
rZhBoYao wrote:
> ChuanqiXu wrote:
> > Agree to @erichkeane 
> With all due respect, this code suggestion doesn't make any sense to me. My best guess is @ChuanqiXu was thinking the order specified by the grammar as noted in [[ https://eel.is/c++draft/dcl.fct.def.general#nt:function-body | dcl.fct.def.general p1 ]]. Even if that was the case, `CompoundStmt` is not quite right either. Also, differentiating `ctor-initializer[opt] compound-statement` and `function-try-block` is meaningless here, hence the name `Other`.
> I adopted the same order as to how `Parser::ParseFunctionDefinition` has always been parsing `function-body`. The order is not significant in any meaningful way as each of the 4 grammar productions of `function-body` is VERY different and mutually exclusive. Putting `Delete` and `Default` upfront not only emphasizes the "specialness" of them but also conveys how we handle `function-body`.
> What say you, @erichkeane ?
Yeah, the order comes from the standard. I think the comment should be consistent with the spec. And for the name, I agree `CompoundStmt` is not accurate indeed... I thought Default should be a good name but there is `Default` already. But I don't feel `Other` is good since the compound-statement is much more common.

> Putting Delete and Default upfront not only emphasizes the "specialness" of them but also conveys how we handle function-body.

This don't makes sense. Generally, we would put common items in front. And the order here shouldn't be related to the implementation.



More information about the cfe-commits mailing list