[PATCH] D145123: Call MarkVirtualMembersReferenced on an actual class definition
Stephan Bergmann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 2 06:50:34 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd812488d3c54: Call MarkVirtualMembersReferenced on an actual class definition (authored by sberg).
Changed prior to commit:
https://reviews.llvm.org/D145123?vs=501669&id=501852#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145123/new/
https://reviews.llvm.org/D145123
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/warn-undefined-internal.cpp
Index: clang/test/SemaCXX/warn-undefined-internal.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/warn-undefined-internal.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
+
+void test1() {
+ struct S { virtual void f(); };
+ // expected-warning at -1{{function 'test1()::S::f' has internal linkage but is not defined}}
+ S s;
+ // expected-note at -1{{used here}}
+}
+
+void test2() {
+ struct S;
+ struct S { virtual void f(); };
+ // expected-warning at -1{{function 'test2()::S::f' has internal linkage but is not defined}}
+ S s;
+ // expected-note at -1{{used here}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -17975,7 +17975,7 @@
// immediately. For all other classes, we mark their virtual members
// at the end of the translation unit.
if (Class->isLocalClass())
- MarkVirtualMembersReferenced(Loc, Class);
+ MarkVirtualMembersReferenced(Loc, Class->getDefinition());
else
VTableUses.push_back(std::make_pair(Class, Loc));
}
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -155,6 +155,8 @@
- Clang now warns by default for C++20 and later about deprecated capture of
``this`` with a capture default of ``=``. This warning can be disabled with
``-Wno-deprecated-this-capture``.
+- Clang had failed to emit some ``-Wundefined-internal`` for members of a local
+ class if that class was first introduced with a forward declaration.
Bug Fixes in This Version
-------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145123.501852.patch
Type: text/x-patch
Size: 1782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230302/c87bfc04/attachment.bin>
More information about the cfe-commits
mailing list