[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / cdtor-fn-try-block.cpp
blobd4d8d829ecdb825007fd7a7cb6c55a383d930ac8
1 // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14
3 int FileScope;
5 struct 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}}
13 FileScope = 12; // ok
14 A a;
15 a.I = 12; // ok
19 struct B {
20 int I;
21 void f();
24 struct 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}}
32 struct D {
33 static int I;
34 static void f();
36 D() try {
37 } catch (...) {
38 I = 12; // ok
39 f(); // ok
42 int D::I;
44 struct E {
45 int I;
46 void f();
47 static int J;
48 static void g();
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}}
55 J = 12; // ok
56 g(); // ok
59 int E::J;
61 struct F {
62 static int I;
63 static void f();
65 int F::I;
67 struct G : F {
68 G() try {
69 } catch (...) {
70 I = 12; // ok
71 f(); // ok
75 struct H {
76 struct A {};
77 enum {
81 H() try {
82 } catch (...) {
83 H::A a; // ok
84 int I = E; // ok
88 struct I {
89 int J;
91 I() {
92 try { // not a function-try-block
93 } catch (...) {
94 J = 12; // ok