diff options
Diffstat (limited to 'test/CXX/class.derived')
-rw-r--r-- | test/CXX/class.derived/class.abstract/p16.cpp | 26 | ||||
-rw-r--r-- | test/CXX/class.derived/class.virtual/p3-0x.cpp | 30 |
2 files changed, 56 insertions, 0 deletions
diff --git a/test/CXX/class.derived/class.abstract/p16.cpp b/test/CXX/class.derived/class.abstract/p16.cpp index 93f905c..c237ed9 100644 --- a/test/CXX/class.derived/class.abstract/p16.cpp +++ b/test/CXX/class.derived/class.abstract/p16.cpp @@ -14,3 +14,29 @@ struct C: A { virtual void a(); virtual void b() = delete; }; + +struct E; +struct F; +struct G; +struct H; +struct D { + virtual E &operator=(const E &); // expected-note {{here}} + virtual F &operator=(const F &); + virtual G &operator=(G&&); + virtual H &operator=(H&&); // expected-note {{here}} + friend struct F; + +private: + D &operator=(const D&) = default; + D &operator=(D&&) = default; + virtual ~D(); // expected-note 2{{here}} +}; +struct E : D {}; // expected-error {{deleted function '~E' cannot override a non-deleted function}} \ + // expected-error {{deleted function 'operator=' cannot override a non-deleted function}} +struct F : D {}; +// No move ctor here, because it would be deleted. +struct G : D {}; // expected-error {{deleted function '~G' cannot override a non-deleted function}} +struct H : D { + H &operator=(H&&) = default; // expected-error {{deleted function 'operator=' cannot override a non-deleted function}} + ~H(); +}; diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp index 16f9828..6a02a86 100644 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -100,3 +100,33 @@ namespace PR13499 { Y<X> y; Z<X> z; // expected-note {{in instantiation of}} } + +namespace MemberOfUnknownSpecialization { + template<typename T> struct A { + struct B {}; + struct C : B { + void f() override; + }; + }; + + template<> struct A<int>::B { + virtual void f(); + }; + // ok + A<int>::C c1; + + template<> struct A<char>::B { + void f(); + }; + // expected-error@-13 {{only virtual member functions can be marked 'override'}} + // expected-note@+1 {{in instantiation of}} + A<char>::C c2; + + template<> struct A<double>::B { + virtual void f() final; + }; + // expected-error@-20 {{declaration of 'f' overrides a 'final' function}} + // expected-note@-3 {{here}} + // expected-note@+1 {{in instantiation of}} + A<double>::C c3; +} |