xref: /aosp_15_r20/external/clang/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -fsyntax-only -verify
2*67e74705SXin Li struct A {
AA3*67e74705SXin Li   A() { f(); } // expected-warning {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
~AA4*67e74705SXin Li   ~A() { f(); } // expected-warning {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
5*67e74705SXin Li 
6*67e74705SXin Li   virtual void f() = 0; // expected-note 2 {{'f' declared here}}
7*67e74705SXin Li };
8*67e74705SXin Li 
9*67e74705SXin Li // Don't warn (or note) when calling the function on a pointer. (PR10195)
10*67e74705SXin Li struct B {
11*67e74705SXin Li   A *a;
BB12*67e74705SXin Li   B() { a->f(); };
~BB13*67e74705SXin Li   ~B() { a->f(); };
14*67e74705SXin Li };
15*67e74705SXin Li 
16*67e74705SXin Li // Don't warn if the call is fully qualified. (PR23215)
17*67e74705SXin Li struct C {
18*67e74705SXin Li     virtual void f() = 0;
CC19*67e74705SXin Li     C() {
20*67e74705SXin Li         C::f();
21*67e74705SXin Li     }
22*67e74705SXin Li };
23