This revision was automatically updated to reflect the committed changes. Closed by commit rG9180f8a57436: Don't report "main" as missing a prototype in freestanding mode (authored by void).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D70588/new/ https://reviews.llvm.org/D70588 Files: clang/lib/Sema/SemaDecl.cpp clang/test/Sema/no-warn-missing-prototype.c Index: clang/test/Sema/no-warn-missing-prototype.c =================================================================== --- /dev/null +++ clang/test/Sema/no-warn-missing-prototype.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s +// expected-no-diagnostics +int main() { + return 0; +} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -13319,8 +13319,10 @@ return false; // Don't warn about 'main'. - if (FD->isMain()) - return false; + if (isa<TranslationUnitDecl>(FD->getDeclContext()->getRedeclContext())) + if (IdentifierInfo *II = FD->getIdentifier()) + if (II->isStr("main")) + return false; // Don't warn about inline functions. if (FD->isInlined())
Index: clang/test/Sema/no-warn-missing-prototype.c =================================================================== --- /dev/null +++ clang/test/Sema/no-warn-missing-prototype.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes-x c -ffreestanding -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wmissing-prototypes -x c++ -ffreestanding -verify %s +// expected-no-diagnostics +int main() { + return 0; +} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -13319,8 +13319,10 @@ return false; // Don't warn about 'main'. - if (FD->isMain()) - return false; + if (isa<TranslationUnitDecl>(FD->getDeclContext()->getRedeclContext())) + if (IdentifierInfo *II = FD->getIdentifier()) + if (II->isStr("main")) + return false; // Don't warn about inline functions. if (FD->isInlined())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits