| 1 |
#define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type"))) |
| 2 |
|
| 3 |
template <class T> |
| 4 |
struct MOZ_NEEDS_NO_VTABLE_TYPE PickyConsumer { // expected-error {{'PickyConsumer<B>' cannot be instantiated because 'B' has a VTable}} expected-error {{'PickyConsumer<E>' cannot be instantiated because 'E' has a VTable}} expected-error {{'PickyConsumer<F>' cannot be instantiated because 'F' has a VTable}} expected-error {{'PickyConsumer<G>' cannot be instantiated because 'G' has a VTable}} |
| 5 |
T *m; |
| 6 |
}; |
| 7 |
|
| 8 |
template <class T> |
| 9 |
struct MOZ_NEEDS_NO_VTABLE_TYPE PickyConsumer_A { // expected-error {{'PickyConsumer_A<B>' cannot be instantiated because 'B' has a VTable}} expected-error {{'PickyConsumer_A<E>' cannot be instantiated because 'E' has a VTable}} expected-error {{'PickyConsumer_A<F>' cannot be instantiated because 'F' has a VTable}} expected-error {{'PickyConsumer_A<G>' cannot be instantiated because 'G' has a VTable}} |
| 10 |
T *m; |
| 11 |
}; |
| 12 |
template <class T> |
| 13 |
struct PickyConsumerWrapper { |
| 14 |
PickyConsumer_A<T> m; // expected-note {{bad instantiation of 'PickyConsumer_A<B>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_A<E>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_A<F>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_A<G>' requested here}} |
| 15 |
}; |
| 16 |
|
| 17 |
template <class T> |
| 18 |
struct MOZ_NEEDS_NO_VTABLE_TYPE PickyConsumer_B { // expected-error {{'PickyConsumer_B<B>' cannot be instantiated because 'B' has a VTable}} expected-error {{'PickyConsumer_B<E>' cannot be instantiated because 'E' has a VTable}} expected-error {{'PickyConsumer_B<F>' cannot be instantiated because 'F' has a VTable}} expected-error {{'PickyConsumer_B<G>' cannot be instantiated because 'G' has a VTable}} |
| 19 |
T *m; |
| 20 |
}; |
| 21 |
template <class T> |
| 22 |
struct PickyConsumerSubclass : PickyConsumer_B<T> {}; // expected-note {{bad instantiation of 'PickyConsumer_B<B>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_B<E>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_B<F>' requested here}} expected-note {{bad instantiation of 'PickyConsumer_B<G>' requested here}} |
| 23 |
|
| 24 |
template <class T> |
| 25 |
struct NonPickyConsumer { |
| 26 |
T *m; |
| 27 |
}; |
| 28 |
|
| 29 |
struct A {}; |
| 30 |
struct B : virtual A {}; |
| 31 |
struct C : A {}; |
| 32 |
struct D { |
| 33 |
void d(); |
| 34 |
}; |
| 35 |
struct E { |
| 36 |
virtual void e(); |
| 37 |
}; |
| 38 |
struct F : E { |
| 39 |
void e() final; |
| 40 |
}; |
| 41 |
struct G { |
| 42 |
virtual void e() = 0; |
| 43 |
}; |
| 44 |
|
| 45 |
void f() { |
| 46 |
{ |
| 47 |
PickyConsumer<A> a1; |
| 48 |
PickyConsumerWrapper<A> a2; |
| 49 |
PickyConsumerSubclass<A> a3; |
| 50 |
NonPickyConsumer<A> a4; |
| 51 |
} |
| 52 |
|
| 53 |
{ |
| 54 |
PickyConsumer<B> a1; // expected-note {{bad instantiation of 'PickyConsumer<B>' requested here}} |
| 55 |
PickyConsumerWrapper<B> a2; |
| 56 |
PickyConsumerSubclass<B> a3; |
| 57 |
NonPickyConsumer<B> a4; |
| 58 |
} |
| 59 |
|
| 60 |
{ |
| 61 |
PickyConsumer<C> a1; |
| 62 |
PickyConsumerWrapper<C> a2; |
| 63 |
PickyConsumerSubclass<C> a3; |
| 64 |
NonPickyConsumer<C> a4; |
| 65 |
} |
| 66 |
|
| 67 |
{ |
| 68 |
PickyConsumer<D> a1; |
| 69 |
PickyConsumerWrapper<D> a2; |
| 70 |
PickyConsumerSubclass<D> a3; |
| 71 |
NonPickyConsumer<D> a4; |
| 72 |
} |
| 73 |
|
| 74 |
{ |
| 75 |
PickyConsumer<E> a1; // expected-note {{bad instantiation of 'PickyConsumer<E>' requested here}} |
| 76 |
PickyConsumerWrapper<E> a2; |
| 77 |
PickyConsumerSubclass<E> a3; |
| 78 |
NonPickyConsumer<E> a4; |
| 79 |
} |
| 80 |
|
| 81 |
{ |
| 82 |
PickyConsumer<F> a1; // expected-note {{bad instantiation of 'PickyConsumer<F>' requested here}} |
| 83 |
PickyConsumerWrapper<F> a2; |
| 84 |
PickyConsumerSubclass<F> a3; |
| 85 |
NonPickyConsumer<F> a4; |
| 86 |
} |
| 87 |
|
| 88 |
{ |
| 89 |
PickyConsumer<G> a1; // expected-note {{bad instantiation of 'PickyConsumer<G>' requested here}} |
| 90 |
PickyConsumerWrapper<G> a2; |
| 91 |
PickyConsumerSubclass<G> a3; |
| 92 |
NonPickyConsumer<G> a4; |
| 93 |
} |
| 94 |
} |