]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaCXX/warn-unreachable.cpp
Update clang to r108243.
[FreeBSD/FreeBSD.git] / test / SemaCXX / warn-unreachable.cpp
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
2
3 int &halt() __attribute__((noreturn));
4 int &live();
5 int dead();
6 int liveti() throw(int);
7 int (*livetip)() throw(int);
8
9 int test1() {
10   try {
11     live();
12   } catch (int i) {
13     live();
14   }
15   return 1;
16 }
17
18 void test2() {
19   try {
20     live();
21   } catch (int i) {
22     live();
23   }
24   try {
25     liveti();
26   } catch (int i) {
27     live();
28   }
29   try {
30     livetip();
31   } catch (int i) {
32     live();
33   }
34   throw 1;
35   dead();       // expected-warning {{will never be executed}}
36 }
37
38
39 void test3() {
40   halt()
41     --;         // expected-warning {{will never be executed}}
42   halt()
43     ?           // expected-warning {{will never be executed}}
44     dead() : dead();
45   live(),
46     float       // expected-warning {{will never be executed}}
47       (halt());
48 }
49
50 void test4() {
51   struct S {
52     int mem;
53   } s;
54   S &foor();
55   halt(), foor()// expected-warning {{will never be executed}}
56     .mem;       
57 }
58
59 void test5() {
60   struct S {
61     int mem;
62   } s;
63   S &foor() __attribute__((noreturn));
64   foor()
65     .mem;       // expected-warning {{will never be executed}}
66 }
67
68 void test6() {
69   struct S {
70     ~S() { }
71     S(int i) { }
72   };
73   live(),
74     S            // expected-warning {{will never be executed}}
75       (halt());
76 }