1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -Wunreachable-code -fblocks -verify %s 2 3 int j; 4 void bar() { } 5 int test1() { 6 for (int i = 0; 7 i != 10; 8 ++i) { // expected-warning {{will never be executed}} 9 if (j == 23) // missing {}'s 10 bar(); 11 return 1; 12 } 13 return 0; 14 return 1; // expected-warning {{will never be executed}} 15 } 16 17 void test2(int i) { 18 switch (i) { 19 case 0: 20 break; 21 bar(); // expected-warning {{will never be executed}} 22 case 2: 23 switch (i) { 24 default: 25 a: goto a; 26 } 27 bar(); // expected-warning {{will never be executed}} 28 } 29 b: goto b; 30 bar(); // expected-warning {{will never be executed}} 31 } 32 33 void test3() { 34 ^{ return; 35 bar(); // expected-warning {{will never be executed}} 36 }(); 37 while (++j) { 38 continue; 39 bar(); // expected-warning {{will never be executed}} 40 } 41 } 42 43 // PR 6130 - Don't warn about bogus unreachable code with throw's and 44 // temporary objects. 45 class PR6130 { 46 public: 47 PR6130(); 48 ~PR6130(); 49 }; 50 51 int pr6130(unsigned i) { 52 switch(i) { 53 case 0: return 1; 54 case 1: return 2; 55 default: 56 throw PR6130(); // no-warning 57 } 58 } 59