[PATCH] D122981: [Clang] Diagnose incomplete return/param types only when function is not deleted
Chuanqi Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 5 20:39:57 PDT 2022
ChuanqiXu added inline comments.
================
Comment at: clang/lib/Sema/SemaDecl.cpp:14461
if (!ResultType->isDependentType() && !ResultType->isVoidType() &&
- !FD->isInvalidDecl() &&
+ !FD->isInvalidDecl() && !FnDeleted &&
RequireCompleteType(FD->getLocation(), ResultType,
----------------
rZhBoYao wrote:
> ChuanqiXu wrote:
> > I think we could remove the use of `FnDeleted` by the use of `FD->isDeleted()`. Also we should constrain the behavior only if std >= 11.
> I tried `FD->isDeleted()` at first only to find out it always returns `false`. Looks like it's not handled until [[ https://github.com/llvm/llvm-project/blob/634bf829a8d289371d5b5a50b787596124228898/clang/lib/Parse/Parser.cpp#L1342 | Parser.cpp:1342 ]]
>
> Also, looks like deleted functions are implemented as an extension. A warning is issued at [[ https://github.com/llvm/llvm-project/blob/634bf829a8d289371d5b5a50b787596124228898/clang/lib/Parse/Parser.cpp#L1338-L1341 | Parser.cpp:1338 ]] if language mode < C++11
I see. My suggestion might be to defer the diagnose message after we set `FD->setDeletedAsWritten()`. I understand it might be harder. But the current implementation looks a little bit not good... (redundant variables and passing information by argument)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122981/new/
https://reviews.llvm.org/D122981
More information about the cfe-commits
mailing list