[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / except / except.handle / p16.cpp
blob86ced1ae42879b8fe97d4ed1db408b40e319937c
1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
3 // The object declared in an exception-declaration or, if the
4 // exception-declaration does not specify a name, a temporary (12.2)
5 // is copy-initialized (8.5) from the exception object.
6 //
7 template<typename T>
8 class X {
9 T* ptr;
11 public:
12 X(const X<T> &) {
13 int *ip = 0;
14 ptr = ip; // expected-error{{incompatible pointer types assigning to 'float *' from 'int *'}}
17 ~X() {
18 float *fp = 0;
19 ptr = fp; // expected-error{{incompatible pointer types assigning to 'int *' from 'float *'}}
23 void f() {
24 try {
25 } catch (X<float>) { // expected-note{{instantiation}}
26 // copy constructor
27 } catch (X<int> xi) { // expected-note{{instantiation}}
28 // destructor
32 struct Abstract {
33 virtual void f() = 0; // expected-note{{pure virtual}}
36 void g() {
37 try {
38 } catch (Abstract) { // expected-error{{variable type 'Abstract' is an abstract class}}