Debian Codegraph @

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

raw
1 /* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */
2
3 extern int foo2 (int x, ...);
4
5 struct str
6 {
7 int a, b;
8 };
9
10 struct str
11 cstruct (int x)
12 {
13 if (x < 10)
14 [[clang::musttail]] return cstruct (x + 1);
15 return ((struct str){ x, 0 });
16 }
17
18 int
19 foo (int x)
20 {
21 if (x < 10)
22 [[clang::musttail]] return foo2 (x, 29);
23 if (x < 100)
24 {
25 int k = foo (x + 1);
26 [[clang::musttail]] return k; /* { dg-error "cannot tail-call: " } */
27 }
28 return x;
29 }