[clang] [Clang] add ext warning for missing return in 'main' for C89 mode (PR #134617)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 7 06:45:36 PDT 2025
================
@@ -16232,7 +16232,9 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
// If the function implicitly returns zero (like 'main') or is naked,
// don't complain about missing return statements.
- if (FD->hasImplicitReturnZero() || FD->hasAttr<NakedAttr>())
+ if ((FD->hasImplicitReturnZero() &&
+ (getLangOpts().CPlusPlus || getLangOpts().C99 || !FD->isMain())) ||
----------------
a-tarasyuk wrote:
@AaronBallman, thanks for the feedback. Do you mean we should avoid setting setHasImplicitReturnZero for C89?
https://github.com/llvm/llvm-project/blob/0ab2061c4fd0feac8b142ff76ed823534bebc634/clang/lib/Sema/SemaDecl.cpp#L12445
https://github.com/llvm/llvm-project/pull/134617
More information about the cfe-commits
mailing list