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