p5-virtual.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
  2. // Compatibility of virtual functions.
  3. struct A
  4. {
  5. };
  6. struct B1 : A
  7. {
  8. };
  9. struct B2 : A
  10. {
  11. };
  12. struct D : B1, B2
  13. {
  14. };
  15. struct P : private A
  16. {
  17. };
  18. struct Base
  19. {
  20. virtual void f1() throw();
  21. virtual void f2() throw(int, float);
  22. virtual void f3() throw(int, float);
  23. virtual void f4() throw(A);
  24. virtual void f5() throw(A, int, float);
  25. virtual void f6();
  26. virtual void f7() noexcept;
  27. virtual void f8() noexcept;
  28. virtual void f9() noexcept(false);
  29. virtual void f10() noexcept(false);
  30. virtual void f11() throw();
  31. virtual void f12() noexcept;
  32. virtual void f13() noexcept(false);
  33. virtual void f14() throw(int);
  34. virtual void f15();
  35. virtual void f16();
  36. virtual void g1() throw(); // expected-note {{overridden virtual function is here}}
  37. virtual void g2() throw(int); // expected-note {{overridden virtual function is here}}
  38. virtual void g3() throw(A); // expected-note {{overridden virtual function is here}}
  39. virtual void g4() throw(B1); // expected-note {{overridden virtual function is here}}
  40. virtual void g5() throw(A); // expected-note {{overridden virtual function is here}}
  41. virtual void g6() noexcept; // expected-note {{overridden virtual function is here}}
  42. virtual void g7() noexcept; // expected-note {{overridden virtual function is here}}
  43. virtual void g8() noexcept; // expected-note {{overridden virtual function is here}}
  44. virtual void g9() throw(); // expected-note {{overridden virtual function is here}}
  45. virtual void g10() throw(int); // expected-note {{overridden virtual function is here}}
  46. };
  47. struct Derived : Base
  48. {
  49. virtual void f1() throw();
  50. virtual void f2() throw(float, int);
  51. virtual void f3() throw(float);
  52. virtual void f4() throw(B1);
  53. virtual void f5() throw(B1, B2, int);
  54. virtual void f6() throw(B2, B2, int, float, char, double, bool);
  55. virtual void f7() noexcept;
  56. virtual void f8() noexcept(true);
  57. virtual void f9() noexcept(true);
  58. virtual void f10() noexcept(false);
  59. virtual void f11() noexcept;
  60. virtual void f12() throw();
  61. virtual void f13() throw(int);
  62. virtual void f14() noexcept(true);
  63. virtual void f15() noexcept;
  64. virtual void f16() throw();
  65. virtual void g1() throw(int); // expected-error {{exception specification of overriding function is more lax}}
  66. virtual void g2(); // expected-error {{exception specification of overriding function is more lax}}
  67. virtual void g3() throw(D); // expected-error {{exception specification of overriding function is more lax}}
  68. virtual void g4() throw(A); // expected-error {{exception specification of overriding function is more lax}}
  69. virtual void g5() throw(P); // expected-error {{exception specification of overriding function is more lax}}
  70. virtual void g6() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
  71. virtual void g7(); // expected-error {{exception specification of overriding function is more lax}}
  72. virtual void g8() throw(int); // expected-error {{exception specification of overriding function is more lax}}
  73. virtual void g9() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
  74. virtual void g10() noexcept(false); // expected-error {{exception specification of overriding function is more lax}}
  75. };