diff options
Diffstat (limited to 'test/SemaCXX/devirtualize-vtable-marking.cpp')
-rw-r--r-- | test/SemaCXX/devirtualize-vtable-marking.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/SemaCXX/devirtualize-vtable-marking.cpp b/test/SemaCXX/devirtualize-vtable-marking.cpp index fc3e8ce..1b32182 100644 --- a/test/SemaCXX/devirtualize-vtable-marking.cpp +++ b/test/SemaCXX/devirtualize-vtable-marking.cpp @@ -1,29 +1,32 @@ // RUN: %clang_cc1 -verify -std=c++11 %s - +// expected-no-diagnostics template <typename T> struct OwnPtr { T *p; ~OwnPtr() { - // expected-error@+1 {{invalid application of 'sizeof'}} static_assert(sizeof(T) > 0, "incomplete T"); delete p; } }; namespace use_vtable_for_vcall { -struct Incomplete; // expected-note {{forward declaration}} +struct Incomplete; struct A { virtual ~A() {} virtual void m() {} }; -struct B : A { // expected-note {{in instantiation}} +struct B : A { B(); virtual void m() { } virtual void m2() { static_cast<A *>(this)->m(); } OwnPtr<Incomplete> m_sqlError; }; -B *f() { - return new B(); +void f() { + // Since B's constructor is declared out of line, nothing in this file + // references a vtable, so the destructor doesn't get built. + A *b = new B(); + b->m(); + delete b; } } |