aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/musttail3.c
blob: 7499fd6460b47c329f40bde11e9bca644c6219e5 (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
29
/* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */

extern int foo2 (int x, ...);

struct str
{
  int a, b;
};

struct str
cstruct (int x)
{
  if (x < 10)
    [[clang::musttail]] return cstruct (x + 1);
  return ((struct str){ x, 0 });
}

int
foo (int x)
{
  if (x < 10)
    [[clang::musttail]] return foo2 (x, 29);
  if (x < 100)
    {
      int k = foo (x + 1);
      [[clang::musttail]] return k;	/* { dg-error "cannot tail-call: " } */
    }
  return x;
}