diff options
Diffstat (limited to 'test/CXX/class.derived/class.virtual/p3-0x.cpp')
-rw-r--r-- | test/CXX/class.derived/class.virtual/p3-0x.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp index c4a401b..16f9828 100644 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -20,9 +20,15 @@ struct A { template<typename T> struct B : A { + // FIXME: Diagnose this. virtual void f(T) override; }; +template<typename T> +struct C : A { + virtual void f(int) override; // expected-error {{does not override}} +}; + } namespace Test3 { @@ -51,3 +57,46 @@ struct D : B { }; } + +namespace PR13499 { + struct X { + virtual void f(); + virtual void h(); + }; + template<typename T> struct A : X { + void f() override; + void h() final; + }; + template<typename T> struct B : X { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + B<int> b; // no-note + template<typename T> struct C : T { + void g() override; + void i() final; + }; + template<typename T> struct D : X { + virtual void g() override; // expected-error {{does not override}} + virtual void i() final; + }; + template<typename...T> struct E : X { + void f(T...) override; + void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} + void h(T...) final; + void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + // FIXME: Diagnose these in the template definition, not in the instantiation. + E<> e; // expected-note {{in instantiation of}} + + template<typename T> struct Y : T { + void f() override; + void h() final; + }; + template<typename T> struct Z : T { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + Y<X> y; + Z<X> z; // expected-note {{in instantiation of}} +} |