xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/virtual-member-functions-key-function.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc struct A {
3*f4a2713aSLionel Sambuc   virtual ~A();
4*f4a2713aSLionel Sambuc };
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc struct B : A {  // expected-error {{no suitable member 'operator delete' in 'B'}}
BB7*f4a2713aSLionel Sambuc   B() { } // expected-note {{implicit destructor for 'B' first required here}}
8*f4a2713aSLionel Sambuc   void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
9*f4a2713aSLionel Sambuc };
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc struct C : A {  // expected-error {{no suitable member 'operator delete' in 'C'}}
12*f4a2713aSLionel Sambuc   void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
13*f4a2713aSLionel Sambuc };
14*f4a2713aSLionel Sambuc 
f()15*f4a2713aSLionel Sambuc void f() {
16*f4a2713aSLionel Sambuc   (void)new B;
17*f4a2713aSLionel Sambuc   (void)new C; // expected-note {{implicit destructor for 'C' first required here}}
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc // Make sure that the key-function computation is consistent when the
21*f4a2713aSLionel Sambuc // first virtual member function of a nested class has an inline body.
22*f4a2713aSLionel Sambuc struct Outer {
23*f4a2713aSLionel Sambuc   struct Inner {
fOuter::Inner24*f4a2713aSLionel Sambuc     virtual void f() { }
25*f4a2713aSLionel Sambuc     void g();
26*f4a2713aSLionel Sambuc   };
27*f4a2713aSLionel Sambuc };
28*f4a2713aSLionel Sambuc 
g()29*f4a2713aSLionel Sambuc void Outer::Inner::g() { }
30