brintos

brintos / llvm-project-archived public Read only

0
0
Text · 966 B · 86ced1a Raw
41 lines · cpp
1// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s2 3// The object declared in an exception-declaration or, if the4// exception-declaration does not specify a name, a temporary (12.2)5// is copy-initialized (8.5) from the exception object.6//7template<typename T>8class X {9  T* ptr;10 11public:12  X(const X<T> &) {13    int *ip = 0;14    ptr = ip; // expected-error{{incompatible pointer types assigning to 'float *' from 'int *'}}15  }16 17  ~X() {18    float *fp = 0;19    ptr = fp; // expected-error{{incompatible pointer types assigning to 'int *' from 'float *'}}20  }21};22 23void f() {24  try {25  } catch (X<float>) { // expected-note{{instantiation}}26    // copy constructor27  } catch (X<int> xi) { // expected-note{{instantiation}}28    // destructor29  }30}31 32struct Abstract {33  virtual void f() = 0; // expected-note{{pure virtual}}34};35 36void g() {37  try {38  } catch (Abstract) { // expected-error{{variable type 'Abstract' is an abstract class}}39  }40}41