Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) |
michael@0 | 2 | // Ignore warnings not related to static analysis here |
michael@0 | 3 | #pragma GCC diagnostic ignored "-Woverloaded-virtual" |
michael@0 | 4 | |
michael@0 | 5 | struct S { |
michael@0 | 6 | virtual void f() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 7 | virtual void g() MOZ_MUST_OVERRIDE; |
michael@0 | 8 | virtual void h() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 9 | }; |
michael@0 | 10 | struct C : S { // expected-error {{'C' must override 'f'}} expected-error {{'C' must override 'h'}} |
michael@0 | 11 | virtual void g() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 12 | virtual void h(int); |
michael@0 | 13 | void q() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 14 | }; |
michael@0 | 15 | struct D : C { // expected-error {{'D' must override 'g'}} expected-error {{'D' must override 'q'}} |
michael@0 | 16 | virtual void f(); |
michael@0 | 17 | }; |
michael@0 | 18 | |
michael@0 | 19 | struct Base { |
michael@0 | 20 | virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 21 | void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 22 | static void StaticMethod() MOZ_MUST_OVERRIDE; |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | struct DoesNotPropagate : Base { |
michael@0 | 26 | virtual void VirtMethod(); |
michael@0 | 27 | void NonVirtMethod(); |
michael@0 | 28 | static void StaticMethod(); |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | struct Final : DoesNotPropagate { }; |
michael@0 | 32 | |
michael@0 | 33 | struct Propagates : Base { |
michael@0 | 34 | virtual void VirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 35 | void NonVirtMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 36 | static void StaticMethod() MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | struct FailsFinal : Propagates { }; // expected-error {{'FailsFinal' must override 'VirtMethod'}} expected-error {{'FailsFinal' must override 'NonVirtMethod'}} expected-error {{'FailsFinal' must override 'StaticMethod'}} |
michael@0 | 40 | |
michael@0 | 41 | struct WrongOverload : Base { // expected-error {{'WrongOverload' must override 'VirtMethod'}} expected-error {{'WrongOverload' must override 'NonVirtMethod'}} |
michael@0 | 42 | virtual void VirtMethod() const; |
michael@0 | 43 | void NonVirtMethod(int param); |
michael@0 | 44 | static void StaticMethod(); |
michael@0 | 45 | }; |
michael@0 | 46 | |
michael@0 | 47 | namespace A { namespace B { namespace C { |
michael@0 | 48 | struct Param {}; |
michael@0 | 49 | struct Base { |
michael@0 | 50 | void f(Param p) MOZ_MUST_OVERRIDE; // expected-note {{function to override is here}} |
michael@0 | 51 | }; |
michael@0 | 52 | }}} |
michael@0 | 53 | |
michael@0 | 54 | struct Param {}; |
michael@0 | 55 | |
michael@0 | 56 | struct Derived : A::B::C::Base { |
michael@0 | 57 | typedef A::B::C::Param Typedef; |
michael@0 | 58 | void f(Typedef t); |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | struct BadDerived : A::B::C::Base { // expected-error {{'BadDerived' must override 'f'}} |
michael@0 | 62 | void f(Param p); |
michael@0 | 63 | }; |