summaryrefslogtreecommitdiffstats
path: root/build/clang-plugin/tests/TestOverrideBaseCall.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /build/clang-plugin/tests/TestOverrideBaseCall.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'build/clang-plugin/tests/TestOverrideBaseCall.cpp')
-rw-r--r--build/clang-plugin/tests/TestOverrideBaseCall.cpp175
1 files changed, 175 insertions, 0 deletions
diff --git a/build/clang-plugin/tests/TestOverrideBaseCall.cpp b/build/clang-plugin/tests/TestOverrideBaseCall.cpp
new file mode 100644
index 000000000..6fdaaad04
--- /dev/null
+++ b/build/clang-plugin/tests/TestOverrideBaseCall.cpp
@@ -0,0 +1,175 @@
+#define MOZ_REQUIRED_BASE_METHOD __attribute__((annotate("moz_required_base_method")))
+
+class Base {
+public:
+ virtual void fo() MOZ_REQUIRED_BASE_METHOD {
+ }
+
+ virtual int foRet() MOZ_REQUIRED_BASE_METHOD {
+ return 0;
+ }
+};
+
+class BaseOne : public Base {
+public:
+ virtual void fo() MOZ_REQUIRED_BASE_METHOD {
+ Base::fo();
+ }
+};
+
+class BaseSecond : public Base {
+public:
+ virtual void fo() MOZ_REQUIRED_BASE_METHOD {
+ Base::fo();
+ }
+};
+
+class Deriv : public BaseOne, public BaseSecond {
+public:
+ void func() {
+ }
+
+ void fo() {
+ func();
+ BaseSecond::fo();
+ BaseOne::fo();
+ }
+};
+
+class DerivSimple : public Base {
+public:
+ void fo() { // expected-error {{Method Base::fo must be called in all overrides, but is not called in this override defined for class DerivSimple}}
+ }
+};
+
+class BaseVirtualOne : public virtual Base {
+};
+
+class BaseVirtualSecond: public virtual Base {
+};
+
+class DerivVirtual : public BaseVirtualOne, public BaseVirtualSecond {
+public:
+ void fo() {
+ Base::fo();
+ }
+};
+
+class DerivIf : public Base {
+public:
+ void fo() {
+ if (true) {
+ Base::fo();
+ }
+ }
+};
+
+class DerivIfElse : public Base {
+public:
+ void fo() {
+ if (true) {
+ Base::fo();
+ } else {
+ Base::fo();
+ }
+ }
+};
+
+class DerivFor : public Base {
+public:
+ void fo() {
+ for (int i = 0; i < 10; i++) {
+ Base::fo();
+ }
+ }
+};
+
+class DerivDoWhile : public Base {
+public:
+ void fo() {
+ do {
+ Base::fo();
+ } while(false);
+ }
+};
+
+class DerivWhile : public Base {
+public:
+ void fo() {
+ while (true) {
+ Base::fo();
+ break;
+ }
+ }
+};
+
+class DerivAssignment : public Base {
+public:
+ int foRet() {
+ return foRet();
+ }
+};
+
+class BaseOperator {
+private:
+ int value;
+public:
+ BaseOperator() : value(0) {
+ }
+ virtual BaseOperator& operator++() MOZ_REQUIRED_BASE_METHOD {
+ value++;
+ return *this;
+ }
+};
+
+class DerivOperatorErr : public BaseOperator {
+private:
+ int value;
+public:
+ DerivOperatorErr() : value(0) {
+ }
+ DerivOperatorErr& operator++() { // expected-error {{Method BaseOperator::operator++ must be called in all overrides, but is not called in this override defined for class DerivOperatorErr}}
+ value++;
+ return *this;
+ }
+};
+
+class DerivOperator : public BaseOperator {
+private:
+ int value;
+public:
+ DerivOperator() : value(0) {
+ }
+ DerivOperator& operator++() {
+ BaseOperator::operator++();
+ value++;
+ return *this;
+ }
+};
+
+class DerivPrime : public Base {
+public:
+ void fo() {
+ Base::fo();
+ }
+};
+
+class DerivSecondErr : public DerivPrime {
+public:
+ void fo() { // expected-error {{Method Base::fo must be called in all overrides, but is not called in this override defined for class DerivSecondErr}}
+ }
+};
+
+class DerivSecond : public DerivPrime {
+public:
+ void fo() {
+ Base::fo();
+ }
+};
+
+class DerivSecondIndirect : public DerivPrime {
+public:
+ void fo() {
+ DerivPrime::fo();
+ }
+};