summaryrefslogtreecommitdiffstats
path: root/build/clang-plugin/tests/TestMustOverride.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/TestMustOverride.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/TestMustOverride.cpp')
-rw-r--r--build/clang-plugin/tests/TestMustOverride.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/build/clang-plugin/tests/TestMustOverride.cpp b/build/clang-plugin/tests/TestMustOverride.cpp
new file mode 100644
index 000000000..8e053f6c2
--- /dev/null
+++ b/build/clang-plugin/tests/TestMustOverride.cpp
@@ -0,0 +1,63 @@
+#define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
+// Ignore warnings not related to static analysis here
+#pragma GCC diagnostic ignored "-Woverloaded-virtual"
+
+struct S {
+ virtual void f() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ virtual void g() MOZ_MUST_OVERRIDE;
+ virtual void h() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+};
+struct C : S { // expected-error {{'C' must override 'f'}} expected-error {{'C' must override 'h'}}
+ virtual void g() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ virtual void h(int);
+ void q() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+};
+struct D : C { // expected-error {{'D' must override 'g'}} expected-error {{'D' must override 'q'}}
+ virtual void f();
+};
+
+struct Base {
+ virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ static void StaticMethod() MOZ_MUST_OVERRIDE;
+};
+
+struct DoesNotPropagate : Base {
+ virtual void VirtMethod();
+ void NonVirtMethod();
+ static void StaticMethod();
+};
+
+struct Final : DoesNotPropagate { };
+
+struct Propagates : Base {
+ virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ static void StaticMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+};
+
+struct FailsFinal : Propagates { }; // expected-error {{'FailsFinal' must override 'VirtMethod'}} expected-error {{'FailsFinal' must override 'NonVirtMethod'}} expected-error {{'FailsFinal' must override 'StaticMethod'}}
+
+struct WrongOverload : Base { // expected-error {{'WrongOverload' must override 'VirtMethod'}} expected-error {{'WrongOverload' must override 'NonVirtMethod'}}
+ virtual void VirtMethod() const;
+ void NonVirtMethod(int param);
+ static void StaticMethod();
+};
+
+namespace A { namespace B { namespace C {
+ struct Param {};
+ struct Base {
+ void f(Param p) MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}}
+ };
+}}}
+
+struct Param {};
+
+struct Derived : A::B::C::Base {
+ typedef A::B::C::Param Typedef;
+ void f(Typedef t);
+};
+
+struct BadDerived : A::B::C::Base { // expected-error {{'BadDerived' must override 'f'}}
+ void f(Param p);
+};