[clang] 85ee1d3 - Revert "Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static""

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 9 13:13:09 PST 2022


Author: David Blaikie
Date: 2022-03-09T21:12:56Z
New Revision: 85ee1d3ca1d06b6bd3477515b8d0c72c8df7c069

URL: https://github.com/llvm/llvm-project/commit/85ee1d3ca1d06b6bd3477515b8d0c72c8df7c069
DIFF: https://github.com/llvm/llvm-project/commit/85ee1d3ca1d06b6bd3477515b8d0c72c8df7c069.diff

LOG: Revert "Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static""

Regresses:
typedef struct {
  static void  f() {
  }
} a_t;

Causing this to error instead of warn, because the linkage is computed
earlier/too early perhaps. I'll send out a review to see if there's some
other path forward or if this is an acceptable regression, etc.

This reverts commit 275c56226d7fbd6a4d554807374f78d323aa0c1c.

Added: 
    

Modified: 
    clang/lib/Sema/SemaDecl.cpp
    clang/test/SemaCXX/warn-missing-prototypes.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b88d9f2f847fd..fa086ae0f6126 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14210,9 +14210,6 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD,
   if (!FD->isGlobal())
     return false;
 
-  if (!FD->isExternallyVisible())
-    return false;
-
   // Don't warn about C++ member functions.
   if (isa<CXXMethodDecl>(FD))
     return false;

diff  --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp b/clang/test/SemaCXX/warn-missing-prototypes.cpp
index 2880514ee02b7..e8637e5a90eab 100644
--- a/clang/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp
@@ -44,16 +44,3 @@ void j() = delete;
 extern void k() {} // expected-warning {{no previous prototype for function 'k'}}
 // expected-note at -1{{declare 'static' if the function is not intended to be used outside of this translation unit}}
 // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-2]]:{{.*}}-[[@LINE-2]]:{{.*}}}:"{{.*}}"
-
-namespace {
-struct anon { };
-}
-
-// No warning because this has internal linkage despite not being declared
-// explicitly 'static', owing to the internal linkage parameter.
-void l(anon) {
-}
-
-void *operator new(decltype(sizeof(3)) size, const anon &) throw() {
-  return nullptr;
-}


        


More information about the cfe-commits mailing list