Debian Codegraph @

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

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