85 lines · plain
1// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value -Wno-covered-switch-default2 3// This previously triggered a warning from -Wunreachable-code because of4// a busted CFG.5typedef signed char BOOL;6BOOL radar10989084(void) {7 @autoreleasepool { // no-warning8 return __objc_yes;9 }10}11 12// Test the warning works.13void test_unreachable(void) {14 return;15 return; // expected-warning {{will never be executed}}16}17 18#define NO __objc_no19#define YES __objc_yes20#define CONFIG NO21 22// Test that 'NO' and 'YES' are not treated as configuration macros.23int test_NO(void) {24 if (NO)25 return 1; // expected-warning {{will never be executed}}26 else27 return 0;28}29 30int test_YES(void) {31 if (YES)32 return 1;33 else34 return 0; // expected-warning {{will never be executed}}35}36 37int test_CONFIG(void) {38 if (CONFIG)39 return 1;40 else41 return 0;42}43 44// FIXME: This should at some point report a warning45// that the loop increment is unreachable.46void test_loop_increment(id container) {47 for (id x in container) { // no-warning48 break;49 }50}51 52void calledFun(void) {}53 54// Test "silencing" with parentheses.55void test_with_paren_silencing(int x) {56 if (NO) calledFun(); // expected-warning {{will never be executed}} expected-note {{silence by adding parentheses to mark code as explicitly dead}}57 if ((NO)) calledFun(); // no-warning58 59 if (YES) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}60 calledFun();61 else62 calledFun(); // expected-warning {{will never be executed}}63 64 if ((YES))65 calledFun();66 else67 calledFun(); // no-warning68 69 if (!YES) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}70 calledFun(); // expected-warning {{code will never be executed}}71 else72 calledFun();73 74 if ((!YES))75 calledFun(); // no-warning76 else77 calledFun();78 79 if (!(YES))80 calledFun(); // no-warning81 else82 calledFun();83}84 85