warn-unreachable.cpp [plain text]
int &halt() __attribute__((noreturn));
int &live();
int dead();
int liveti() throw(int);
int (*livetip)() throw(int);
int test1() {
try {
live();
} catch (int i) {
live();
}
return 1;
}
void test2() {
try {
live();
} catch (int i) {
live();
}
try {
liveti();
} catch (int i) {
live();
}
try {
livetip();
} catch (int i) {
live();
}
throw 1;
dead(); }
void test3() {
halt()
--; halt() ?
dead() : dead();
live(),
float
(halt()); }
void test4() {
struct S {
int mem;
} s;
S &foor();
halt(), foor() .mem;
}
void test5() {
struct S {
int mem;
} s;
S &foor() __attribute__((noreturn));
foor()
.mem; }
void test6() {
struct S {
~S() { }
S(int i) { }
};
live(),
S
(halt()); }
void isUnreachable();
template <typename T> void test_unreachable_templates() {
T::foo();
isUnreachable(); }
struct TestUnreachableA {
static void foo() __attribute__((noreturn));
};
struct TestUnreachableB {
static void foo();
};
void test_unreachable_templates_harness() {
test_unreachable_templates<TestUnreachableA>();
test_unreachable_templates<TestUnreachableB>();
}
template <typename T> void funcToSpecialize() {}
template <> void funcToSpecialize<int>() {
halt();
dead(); }