Summary:
A user may want to use freestanding mode with the standard "main" entry
point. It's not useful to warn about a missing prototype as it's not
typical to have a prototype for "main".
Reviewers: efriedma, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: aaron.ballman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70588
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())
--- /dev/null
+// 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;
+}