diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -14210,6 +14210,9 @@ if (!FD->isGlobal()) return false; + if (!FD->isExternallyVisible()) + return false; + // Don't warn about C++ member functions. if (isa(FD)) return false; diff --git a/clang/test/SemaCXX/warn-missing-prototypes.cpp b/clang/test/SemaCXX/warn-missing-prototypes.cpp --- a/clang/test/SemaCXX/warn-missing-prototypes.cpp +++ b/clang/test/SemaCXX/warn-missing-prototypes.cpp @@ -44,3 +44,16 @@ extern void k() {} // expected-warning {{no previous prototype for function 'k'}} // expected-note@-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; +}