From 2c2d9dc382a561553a05bf0e96ab67e403beff09 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 8 Apr 2009 15:21:36 +0000 Subject: [PATCH] -Wmissing-prototypes shouldn't complain about main() missing a prototype. Fixes git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68611 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 3 ++- test/Sema/warn-missing-prototypes.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 54be9b4c3d..517c492196 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2793,7 +2793,8 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) { // prototype declaration. This warning is issued even if the // definition itself provides a prototype. The aim is to detect // global functions that fail to be declared in header files. - if (!FD->isInvalidDecl() && FD->isGlobal() && !isa(FD)) { + if (!FD->isInvalidDecl() && FD->isGlobal() && !isa(FD) && + !FD->isMain()) { bool MissingPrototype = true; for (const FunctionDecl *Prev = FD->getPreviousDeclaration(); Prev; Prev = Prev->getPreviousDeclaration()) { diff --git a/test/Sema/warn-missing-prototypes.c b/test/Sema/warn-missing-prototypes.c index 20c28d061c..960bb03255 100644 --- a/test/Sema/warn-missing-prototypes.c +++ b/test/Sema/warn-missing-prototypes.c @@ -32,3 +32,5 @@ int f2(int); int f2(); int f2(int x) { return x; } + +int main(void) { return 0; }