[PATCH] D70588: Don't report "main" as missing a prototype in freestanding mode

Bill Wendling via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 12:44:11 PST 2019


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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70588.230709.patch
Type: text/x-patch
Size: 958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191122/1d7eca04/attachment.bin>


More information about the cfe-commits mailing list