Debian Codegraph @

gcc/testsuite/c-c++-common/musttail5.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-std=c23" { target c } } */
3 /* { dg-options "-std=gnu++11" { target c++ } } */
4
5 [[musttail]] int j; /* { dg-warning "attribute" } */
6 __attribute__((musttail)) int k; /* { dg-warning "attribute" } */
7
8 void foo(void)
9 {
10 [[gnu::musttail]] j++; /* { dg-warning "attribute" } */
11 [[gnu::musttail]] if (k > 0) /* { dg-warning "attribute" } */
12 [[gnu::musttail]] k++; /* { dg-warning "attribute" } */
13 }
14
15 int foo2(int p)
16 {
17 [[gnu::musttail(1)]] return foo2(p + 1); /* { dg-error "\(before numeric constant|attribute\)" } */
18 }
19
20 int i;
21
22 int foo3(void)
23 {
24 [[musttail]] i++; /* { dg-warning "attribute" } */
25 [[musttail]] if (i > 10) /* { dg-warning "attribute" } */
26 [[musttail]] return foo2(i); /* { dg-warning "attribute" } */
27 return 0;
28 }