aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/musttail5.c
blob: 234da0d3f2a905c656df537cbb74f37877f11a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* { dg-do compile } */
/* { dg-options "-std=c23" { target c } } */
/* { dg-options "-std=gnu++11" { target c++ } } */

[[musttail]] int j; /* { dg-warning "attribute" } */
__attribute__((musttail)) int k; /* { dg-warning "attribute" } */

void foo(void)
{
  [[gnu::musttail]] j++; /* { dg-warning "attribute" } */
  [[gnu::musttail]] if (k > 0) /* { dg-warning "attribute" } */
    [[gnu::musttail]] k++; /* { dg-warning "attribute" } */
}

int foo2(int p)
{
  [[gnu::musttail(1)]] return foo2(p + 1); /* { dg-error "\(before numeric constant|attribute\)" } */
}

int i;

int foo3(void)
{
  [[musttail]] i++; /* { dg-warning "attribute" } */
  [[musttail]] if (i > 10) /* { dg-warning "attribute" } */
    [[musttail]] return foo2(i); /* { dg-warning "attribute" } */
  return 0;
}