This revision was automatically updated to reflect the committed changes.
Closed by commit rG34b9b1ea4874: Disable -Wmissing-prototypes for internal
linkage functions that aren't… (authored by dblaikie).
Changed prior to commit:
https://reviews.llvm.org/D121328?vs=417989&id=418360#toc
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/anonymous-struct.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/test/SemaCXX/anonymous-struct.cpp
===================================================================
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -183,3 +183,9 @@
void memcpy(); // expected-note {{due to this member}}
} A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
}
+namespace inline_defined_static_member {
+typedef struct { // expected-warning {{anonymous non-C-compatible type}}
+ static void f() { // expected-note {{due to this member}}
+ }
+} A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14233,6 +14233,11 @@
if (FD->isDeleted())
return false;
+ // Don't warn on implicitly local functions (such as having local-typed
+ // parameters).
+ if (!FD->isExternallyVisible())
+ return false;
+
for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
// Ignore any declarations that occur in function or method
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/test/SemaCXX/anonymous-struct.cpp
===================================================================
--- clang/test/SemaCXX/anonymous-struct.cpp
+++ clang/test/SemaCXX/anonymous-struct.cpp
@@ -183,3 +183,9 @@
void memcpy(); // expected-note {{due to this member}}
} A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
}
+namespace inline_defined_static_member {
+typedef struct { // expected-warning {{anonymous non-C-compatible type}}
+ static void f() { // expected-note {{due to this member}}
+ }
+} A; // expected-note {{given name 'A' for linkage purposes by this typedef}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14233,6 +14233,11 @@
if (FD->isDeleted())
return false;
+ // Don't warn on implicitly local functions (such as having local-typed
+ // parameters).
+ if (!FD->isExternallyVisible())
+ return false;
+
for (const FunctionDecl *Prev = FD->getPreviousDecl();
Prev; Prev = Prev->getPreviousDecl()) {
// Ignore any declarations that occur in function or method
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits