[PATCH] D122981: [Clang] Diagnose incomplete return/param types only when function is not deleted

PoYao Chang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 2 09:11:56 PDT 2022


rZhBoYao created this revision.
rZhBoYao added reviewers: ChuanqiXu, rsmith.
rZhBoYao added a project: clang.
Herald added a project: All.
rZhBoYao requested review of this revision.
Herald added a subscriber: cfe-commits.

According to dcl.fct.def.general p2 <https://eel.is/c++draft/dcl.fct.def.general#2.sentence-3> and this <https://stackoverflow.com/questions/70410542/can-one-delete-a-function-returning-an-incomplete-type-in-c>, deleted functions with incomplete return types and parameter types are well-formed.

  struct Incomplete;                   // expected-note{{forward declaration of 'Incomplete'}}
  Incomplete f() = delete;             // well-formed
  Incomplete g(Incomplete a) = delete; // well-formed
  Incomplete h() {}                    // expected-error{{incomplete result type 'Incomplete' in function definition}}

Inspired by this tweet <https://twitter.com/shafikyaghmour/status/1510069442302001157>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122981

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p2.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122981.419989.patch
Type: text/x-patch
Size: 5214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220402/0133f50d/attachment.bin>


More information about the cfe-commits mailing list