]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
Vendor import of clang trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / SemaCXX / warn-pure-virtual-call-from-ctor-dtor.cpp
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -Wcall-to-pure-virtual-from-ctor-dtor
2 struct A {
3   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'}}
4   ~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
6   virtual void f() = 0; // expected-note 2 {{'f' declared here}}
7 };
8
9 // Don't warn (or note) when calling the function on a pointer. (PR10195)
10 struct B {
11   A *a;
12   B() { a->f(); };
13   ~B() { a->f(); };
14 };
15
16 // Don't warn if the call is fully qualified. (PR23215)
17 struct C {
18     virtual void f() = 0;
19     C() {
20         C::f();
21     }
22 };