2010-01-23 23:12:18 +03:00
|
|
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code
|
2009-07-29 03:11:12 +04:00
|
|
|
|
|
|
|
int j;
|
|
|
|
void test1() { // expected-warning {{function could be attribute 'noreturn'}}
|
|
|
|
^ (void) { while (1) { } }(); // expected-warning {{block could be attribute 'noreturn'}}
|
|
|
|
^ (void) { if (j) while (1) { } }();
|
|
|
|
while (1) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
void test2() {
|
|
|
|
if (j) while (1) { }
|
|
|
|
}
|
2009-09-26 07:48:56 +04:00
|
|
|
|
2009-09-26 07:54:06 +04:00
|
|
|
__attribute__((__noreturn__))
|
|
|
|
void test2_positive() {
|
|
|
|
if (j) while (1) { }
|
|
|
|
} // expected-warning{{function declared 'noreturn' should not return}}
|
|
|
|
|
|
|
|
|
2009-09-26 07:48:56 +04:00
|
|
|
// This test case illustrates that we don't warn about the missing return
|
|
|
|
// because the function is marked noreturn and there is an infinite loop.
|
|
|
|
extern int foo_test_3();
|
2010-09-03 04:25:02 +04:00
|
|
|
__attribute__((__noreturn__)) void* test3(int arg) {
|
2009-09-26 07:48:56 +04:00
|
|
|
while (1) foo_test_3();
|
|
|
|
}
|
|
|
|
|
2010-09-03 04:25:02 +04:00
|
|
|
__attribute__((__noreturn__)) void* test3_positive(int arg) {
|
2009-09-26 07:48:56 +04:00
|
|
|
while (0) foo_test_3();
|
|
|
|
} // expected-warning{{function declared 'noreturn' should not return}}
|
2009-10-26 01:43:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
// PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
|
|
|
|
// declared noreturn.
|
|
|
|
void __attribute__((noreturn))
|
|
|
|
test4() {
|
|
|
|
test2_positive();
|
|
|
|
}
|