Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / build / clang-plugin / tests / TestNeedsNoVTableType.cpp
blob9b7c405d80aa5f7211687c388a01861ae473459d
1 #define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type")))
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 };
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;
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}}
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;
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}}
24 template <class T>
25 struct NonPickyConsumer {
26 T *m;
29 struct A {};
30 struct B : virtual A {};
31 struct C : A {};
32 struct D {
33 void d();
35 struct E {
36 virtual void e();
38 struct F : E {
39 void e() final;
41 struct G {
42 virtual void e() = 0;
45 void f() {
47 PickyConsumer<A> a1;
48 PickyConsumerWrapper<A> a2;
49 PickyConsumerSubclass<A> a3;
50 NonPickyConsumer<A> a4;
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;
61 PickyConsumer<C> a1;
62 PickyConsumerWrapper<C> a2;
63 PickyConsumerSubclass<C> a3;
64 NonPickyConsumer<C> a4;
68 PickyConsumer<D> a1;
69 PickyConsumerWrapper<D> a2;
70 PickyConsumerSubclass<D> a3;
71 NonPickyConsumer<D> a4;
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;
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;
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;