p2-0x.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
  2. namespace Test1 {
  3. class A final { }; // expected-note {{'A' declared here}}
  4. class B : A { }; // expected-error {{base 'A' is marked 'final'}}
  5. }
  6. namespace Test2 {
  7. template<typename T> struct A final { }; // expected-note 2 {{'A' declared here}}
  8. struct B : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
  9. template<typename T> struct C : A<T> { }; // expected-error {{base 'A' is marked 'final'}}
  10. struct D : C<int> { }; // expected-note {{in instantiation of template class 'Test2::C<int>' requested here}}
  11. }
  12. namespace Test3 {
  13. template<typename T> struct A { };
  14. template<> struct A<int> final { }; // expected-note {{'A' declared here}}
  15. struct B : A<bool> { };
  16. struct C : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
  17. }
  18. namespace Test4 {
  19. struct A final { virtual void func() = 0; }; // expected-warning {{abstract class is marked 'final'}} expected-note {{unimplemented pure virtual method 'func' in 'A'}}
  20. struct B { virtual void func() = 0; }; // expected-note {{unimplemented pure virtual method 'func' in 'C'}}
  21. struct C final : B { }; // expected-warning {{abstract class is marked 'final'}}
  22. }