Bug 1814798 - pt 1. Add bool to enable/disable PHC at runtime r=glandium
[gecko.git] / build / clang-plugin / tests / TestOverrideBaseCall.cpp
blob6fdaaad04e457e0de49b90ca3c311494562c89e7
1 #define MOZ_REQUIRED_BASE_METHOD __attribute__((annotate("moz_required_base_method")))
3 class Base {
4 public:
5 virtual void fo() MOZ_REQUIRED_BASE_METHOD {
8 virtual int foRet() MOZ_REQUIRED_BASE_METHOD {
9 return 0;
13 class BaseOne : public Base {
14 public:
15 virtual void fo() MOZ_REQUIRED_BASE_METHOD {
16 Base::fo();
20 class BaseSecond : public Base {
21 public:
22 virtual void fo() MOZ_REQUIRED_BASE_METHOD {
23 Base::fo();
27 class Deriv : public BaseOne, public BaseSecond {
28 public:
29 void func() {
32 void fo() {
33 func();
34 BaseSecond::fo();
35 BaseOne::fo();
39 class DerivSimple : public Base {
40 public:
41 void fo() { // expected-error {{Method Base::fo must be called in all overrides, but is not called in this override defined for class DerivSimple}}
45 class BaseVirtualOne : public virtual Base {
48 class BaseVirtualSecond: public virtual Base {
51 class DerivVirtual : public BaseVirtualOne, public BaseVirtualSecond {
52 public:
53 void fo() {
54 Base::fo();
58 class DerivIf : public Base {
59 public:
60 void fo() {
61 if (true) {
62 Base::fo();
67 class DerivIfElse : public Base {
68 public:
69 void fo() {
70 if (true) {
71 Base::fo();
72 } else {
73 Base::fo();
78 class DerivFor : public Base {
79 public:
80 void fo() {
81 for (int i = 0; i < 10; i++) {
82 Base::fo();
87 class DerivDoWhile : public Base {
88 public:
89 void fo() {
90 do {
91 Base::fo();
92 } while(false);
96 class DerivWhile : public Base {
97 public:
98 void fo() {
99 while (true) {
100 Base::fo();
101 break;
106 class DerivAssignment : public Base {
107 public:
108 int foRet() {
109 return foRet();
113 class BaseOperator {
114 private:
115 int value;
116 public:
117 BaseOperator() : value(0) {
119 virtual BaseOperator& operator++() MOZ_REQUIRED_BASE_METHOD {
120 value++;
121 return *this;
125 class DerivOperatorErr : public BaseOperator {
126 private:
127 int value;
128 public:
129 DerivOperatorErr() : value(0) {
131 DerivOperatorErr& operator++() { // expected-error {{Method BaseOperator::operator++ must be called in all overrides, but is not called in this override defined for class DerivOperatorErr}}
132 value++;
133 return *this;
137 class DerivOperator : public BaseOperator {
138 private:
139 int value;
140 public:
141 DerivOperator() : value(0) {
143 DerivOperator& operator++() {
144 BaseOperator::operator++();
145 value++;
146 return *this;
150 class DerivPrime : public Base {
151 public:
152 void fo() {
153 Base::fo();
157 class DerivSecondErr : public DerivPrime {
158 public:
159 void fo() { // expected-error {{Method Base::fo must be called in all overrides, but is not called in this override defined for class DerivSecondErr}}
163 class DerivSecond : public DerivPrime {
164 public:
165 void fo() {
166 Base::fo();
170 class DerivSecondIndirect : public DerivPrime {
171 public:
172 void fo() {
173 DerivPrime::fo();