dblaikie updated this revision to Diff 417985. dblaikie added a comment. Try Dean's suggestion of moving this check further down
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121328/new/ https://reviews.llvm.org/D121328 Files: clang/lib/Sema/SemaDecl.cpp clang/test/SemaCXX/warn-missing-prototypes.cpp Index: clang/test/SemaCXX/warn-missing-prototypes.cpp =================================================================== --- clang/test/SemaCXX/warn-missing-prototypes.cpp +++ 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; +} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14207,6 +14207,9 @@ if (isa<CXXMethodDecl>(FD)) return false; + if (!FD->isExternallyVisible()) + return false; + // Don't warn about 'main'. if (isa<TranslationUnitDecl>(FD->getDeclContext()->getRedeclContext())) if (IdentifierInfo *II = FD->getIdentifier())
Index: clang/test/SemaCXX/warn-missing-prototypes.cpp =================================================================== --- clang/test/SemaCXX/warn-missing-prototypes.cpp +++ 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; +} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -14207,6 +14207,9 @@ if (isa<CXXMethodDecl>(FD)) return false; + if (!FD->isExternallyVisible()) + return false; + // Don't warn about 'main'. if (isa<TranslationUnitDecl>(FD->getDeclContext()->getRedeclContext())) if (IdentifierInfo *II = FD->getIdentifier())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits