]> granicus.if.org Git - clang/commitdiff
-Wmissing-prototypes shouldn't complain about main() missing a prototype.
authorDouglas Gregor <dgregor@apple.com>
Wed, 8 Apr 2009 15:21:36 +0000 (15:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 8 Apr 2009 15:21:36 +0000 (15:21 +0000)
Fixes <rdar://problem/6759522>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68611 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/warn-missing-prototypes.c

index 54be9b4c3dfdad373e5c372e1160e312e5b284fc..517c492196409250af3d7bed4ae88eb10c2f66ec 100644 (file)
@@ -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<CXXMethodDecl>(FD)) {
+  if (!FD->isInvalidDecl() && FD->isGlobal() && !isa<CXXMethodDecl>(FD) &&
+      !FD->isMain()) {
     bool MissingPrototype = true;
     for (const FunctionDecl *Prev = FD->getPreviousDeclaration();
          Prev; Prev = Prev->getPreviousDeclaration()) {
index 20c28d061c179949891ea35a3cbf72ef666b1a17..960bb032554b0623e92d6bd311a1ea256f70d143 100644 (file)
@@ -32,3 +32,5 @@ int f2(int);
 int f2();
 
 int f2(int x) { return x; }
+
+int main(void) { return 0; }