xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/devirtualize-vtable-marking.cpp (revision 340f5e56603e4275faeb89a9aacace41ba22d661)
1 // RUN: %clang_cc1 -verify -std=c++11 %s
2 
3 template <typename T> struct OwnPtr {
4   T *p;
5   ~OwnPtr() {
6     // expected-error@+1 {{invalid application of 'sizeof'}}
7     static_assert(sizeof(T) > 0, "incomplete T");
8     delete p;
9   }
10 };
11 
12 namespace use_vtable_for_vcall {
13 struct Incomplete; // expected-note {{forward declaration}}
14 struct A {
15   virtual ~A() {}
16   virtual void m() {}
17 };
18 struct B : A { // expected-note {{in instantiation}}
19   B();
20   virtual void m() { }
21   virtual void m2() { static_cast<A *>(this)->m(); }
22   OwnPtr<Incomplete> m_sqlError;
23 };
24 
25 B *f() {
26   return new B();
27 }
28 }
29 
30 namespace dont_mark_qualified_vcall {
31 struct Incomplete;
32 struct A {
33   virtual ~A() {}
34   virtual void m() {}
35 };
36 struct B : A {
37   B();
38   // Previously we would mark B's vtable referenced to devirtualize this call to
39   // A::m, even though it's not a virtual call.
40   virtual void m() { A::m(); }
41   OwnPtr<Incomplete> m_sqlError;
42 };
43 
44 B *f() {
45   return new B();
46 }
47 }
48