return-noreturn.c revision 7a128e84006fdabfda4b8bd04f09c2739ed7f824
1// RUN: clang-cc %s -fsyntax-only -verify -fblocks -Wmissing-noreturn 2 3int j; 4void test1() { // expected-warning {{function could be attribute 'noreturn'}} 5 ^ (void) { while (1) { } }(); // expected-warning {{block could be attribute 'noreturn'}} 6 ^ (void) { if (j) while (1) { } }(); 7 while (1) { } 8} 9 10void test2() { 11 if (j) while (1) { } 12} 13 14__attribute__((__noreturn__)) 15void test2_positive() { 16 if (j) while (1) { } 17} // expected-warning{{function declared 'noreturn' should not return}} 18 19 20// This test case illustrates that we don't warn about the missing return 21// because the function is marked noreturn and there is an infinite loop. 22extern int foo_test_3(); 23__attribute__((__noreturn__)) void* test3(int arg) { 24 while (1) foo_test_3(); 25} 26 27__attribute__((__noreturn__)) void* test3_positive(int arg) { 28 while (0) foo_test_3(); 29} // expected-warning{{function declared 'noreturn' should not return}} 30 31 32// PR5298 - -Wmissing-noreturn shouldn't warn if the function is already 33// declared noreturn. 34void __attribute__((noreturn)) 35test4() { 36 test2_positive(); 37} 38