You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
986 B
49 lines
986 B
7 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
7 years ago
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
7 years ago
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
|
||
|
struct E {
|
||
|
E() { printf(" E default constructor, this=%p\n", this); }
|
||
|
E(const E& other) {
|
||
|
printf(" E copy-constructor, this=%p from that=%p\n", this, &other);
|
||
|
}
|
||
|
virtual ~E() { printf(" E destructor, this=%p\n", this); }
|
||
|
};
|
||
|
|
||
|
struct F : public E {
|
||
|
F() { printf(" F default constructor, this=%p\n", this); }
|
||
|
F(const F& other) {
|
||
|
printf(" F copy-constructor, this=%p from that=%p\n", this, &other);
|
||
|
}
|
||
|
virtual ~F() { printf(" F destructor, this=%p\n", this); }
|
||
|
};
|
||
|
|
||
|
__attribute__((noinline)) void f() { throw 20; }
|
||
|
|
||
|
void g() throw(E) {
|
||
|
F e;
|
||
|
throw e;
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
try {
|
||
|
f();
|
||
|
throw 20;
|
||
|
} catch (int e) {
|
||
|
if (e > 0) {
|
||
|
try {
|
||
|
g();
|
||
|
} catch (E e2) {
|
||
|
throw;
|
||
|
}
|
||
|
} else
|
||
|
return e;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|