blob: d4d8d829ecdb825007fd7a7cb6c55a383d930ac8 [file] [log] [blame]
Dimitry Andricb1aa87e2016-01-03 15:55:40 +00001// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14
2
3int FileScope;
4
5struct A {
6 int I;
7 void f();
8 A() try {
9 } catch (...) {
10 I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
11 f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
12
13 FileScope = 12; // ok
14 A a;
15 a.I = 12; // ok
16 }
17};
18
19struct B {
20 int I;
21 void f();
22};
23
24struct C : B {
25 C() try {
26 } catch (...) {
27 I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
28 f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
29 }
30};
31
32struct D {
33 static int I;
34 static void f();
35
36 D() try {
37 } catch (...) {
38 I = 12; // ok
39 f(); // ok
40 }
41};
42int D::I;
43
44struct E {
45 int I;
46 void f();
47 static int J;
48 static void g();
49
50 ~E() try {
51 } catch (...) {
52 I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
53 f(); // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
54
55 J = 12; // ok
56 g(); // ok
57 }
58};
59int E::J;
60
61struct F {
62 static int I;
63 static void f();
64};
65int F::I;
66
67struct G : F {
68 G() try {
69 } catch (...) {
70 I = 12; // ok
71 f(); // ok
72 }
73};
74
75struct H {
76 struct A {};
77 enum {
78 E
79 };
80
81 H() try {
82 } catch (...) {
83 H::A a; // ok
84 int I = E; // ok
85 }
86};
87
88struct I {
89 int J;
90
91 I() {
92 try { // not a function-try-block
93 } catch (...) {
94 J = 12; // ok
95 }
96 }
Aaron Ballman6924dcd2015-09-01 14:49:24 +000097};