Debian Codegraph @

gcc/testsuite/g++.dg/ext/musttail3.C

raw
1 // PR ipa/119376
2 // { dg-do compile { target { musttail && c++11 } } }
3
4 int foo (int &);
5 int bar (int &&);
6 int corge (int *);
7
8 int
9 baz (int &x)
10 {
11 if (x == 1)
12 [[gnu::musttail]] return foo (x);
13 if (x == 2)
14 {
15 int a = 42;
16 [[gnu::musttail]] return foo (a); // { dg-warning "address of automatic variable 'a' passed to 'musttail' call argument" }
17 }
18 if (x == 3)
19 {
20 int a = 42;
21 foo (a);
22 [[gnu::musttail]] return foo (x);
23 }
24 return 0;
25 }
26
27 int
28 qux (int &&x)
29 {
30 [[gnu::musttail]] return bar (x + 1); // { dg-warning "address of local variable passed to 'musttail' call argument" }
31 }
32
33 int
34 freddy (int x)
35 {
36 [[gnu::musttail]] return foo (x); // { dg-warning "address of parameter 'x' passed to 'musttail' call argument" }
37 }