brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · d4d8d82 Raw
97 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++142 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; // ok14    A a;15    a.I = 12; // ok16  }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; // ok39    f(); // ok40  }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; // ok56    g(); // ok57  }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; // ok71    f(); // ok72  }73};74 75struct H {76  struct A {};77  enum {78    E79  };80 81  H() try {82  } catch (...) {83    H::A a; // ok84    int I = E; // ok85  }86};87 88struct I {89  int J;90 91  I() {92    try { // not a function-try-block93    } catch (...) {94      J = 12; // ok95	}96  }97};