[RISCV] Rename a lambda to have plural nouns to reflect that it contains a loop. NFC
[llvm-project.git] / clang / test / Sema / return-noreturn.c
blob8a78aa05d0b0810f219d2acc91bf3e0ee7e7b101
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wmissing-noreturn -Wno-unreachable-code
3 int j;
4 void test1(void) { // expected-warning {{function 'test1' could be declared with attribute 'noreturn'}}
5 ^ (void) { while (1) { } }();
6 ^ (void) { if (j) while (1) { } }();
7 while (1) { }
10 void test2(void) {
11 if (j) while (1) { }
14 __attribute__((__noreturn__))
15 void test2_positive(void) {
16 if (j) while (1) { }
17 } // expected-warning{{function declared 'noreturn' should not return}}
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.
22 extern int foo_test_3(void);
23 __attribute__((__noreturn__)) void* test3(int arg) {
24 while (1) foo_test_3();
27 __attribute__((__noreturn__)) void* test3_positive(int arg) {
28 while (0) foo_test_3();
29 } // expected-warning{{function declared 'noreturn' should not return}}
32 // PR5298 - -Wmissing-noreturn shouldn't warn if the function is already
33 // declared noreturn.
34 void __attribute__((noreturn))
35 test4(void) {
36 test2_positive();
39 // Do not warn here.
40 _Noreturn void test5(void) {
41 test2_positive();
44 void test6(void)
46 (void)^{
47 for(;;)