diff options
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 540f5f2..1c30458 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -16232,7 +16232,12 @@ 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>()) + // Clang implicitly returns 0 in C89 mode, but that's considered an + // extension. The check is necessary to ensure the expected extension + // warning is emitted in C89 mode. + if ((FD->hasImplicitReturnZero() && + (getLangOpts().CPlusPlus || getLangOpts().C99 || !FD->isMain())) || + FD->hasAttr<NakedAttr>()) WP.disableCheckFallThrough(); // MSVC permits the use of pure specifier (=0) on function definition, |