llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp
Stephan Bergmann d812488d3c Call MarkVirtualMembersReferenced on an actual class definition
...rather than on potentially just a declaration.

Without the fix, the newly added clang/test/SemaCXX/warn-undefined-internal.cpp
failed with

> error: 'warning' diagnostics expected but not seen:
>   File /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp Line 12 (directive at /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp:13): function 'test2()::S::f' has internal linkage but is not defined
> error: 'note' diagnostics expected but not seen:
>   File /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp Line 14 (directive at /home/sbergman/github.com/llvm/llvm-project/clang/test/SemaCXX/warn-undefined-internal.cpp:15): used here

(I ran into this when two LibreOffice Clang plugins produced false positive
warnings, as they relied on Decl::isReferenced() returning true for such virtual
member functions of local classes.)

Differential Revision: https://reviews.llvm.org/D145123
2023-03-02 15:50:12 +01:00

17 lines
451 B
C++

// RUN: %clang_cc1 -fsyntax-only -Wundefined-internal -verify %s
void test1() {
struct S { virtual void f(); };
// expected-warning@-1{{function 'test1()::S::f' has internal linkage but is not defined}}
S s;
// expected-note@-1{{used here}}
}
void test2() {
struct S;
struct S { virtual void f(); };
// expected-warning@-1{{function 'test2()::S::f' has internal linkage but is not defined}}
S s;
// expected-note@-1{{used here}}
}