summaryrefslogtreecommitdiff
path: root/tests/headers/inherit-from-template-instantiation-with-vtable.hpp
blob: 562ca0e1b241c6e668edb67dd0dcc9aa1059fb26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// bindgen-flags: -- -std=c++14

// Small test that we handle virtual tables correctly when deriving from a
// template instantiation. This wasn't previously handled at all. Note that when
// inheriting from a template parameter, the type that is instantiated might or
// might not have a virtual table, and we have no way of knowing. We don't
// handle that yet, so no test for it here.

/// This should have an explicit vtable.
template<class T>
class BaseWithVtable {
    T t;

    virtual void hello();
};

/// This should not have an explicit vtable.
class DerivedWithNoVirtualMethods : public BaseWithVtable<char*> {};

/// This should not have an explicit vtable.
class DerivedWithVirtualMethods : public BaseWithVtable<char*> {
    virtual void zoidberg();
};

/// This should not have any vtable.
template<class U>
class BaseWithoutVtable {
    U u;
};

/// This should have an explicit vtable.
class DerivedWithVtable : public BaseWithoutVtable<char*> {
    virtual void leela();
};

/// This should not have any vtable.
class DerivedWithoutVtable : public BaseWithoutVtable<char*> {};