1 // { dg-do compile }
2 // { dg-options "-Wframe-address" }
3
4 static void* const fa[] = {
5 __builtin_frame_address (0),
6 __builtin_frame_address (1), // { dg-warning "builtin_frame_address" }
7 __builtin_frame_address (2), // { dg-warning "builtin_frame_address" }
8 __builtin_frame_address (3), // { dg-warning "builtin_frame_address" }
9 __builtin_frame_address (4) // { dg-warning "builtin_frame_address" }
10 };
11
12
13 static void* const ra[] = {
14 __builtin_return_address (0),
15 __builtin_return_address (1), // { dg-warning "builtin_return_address" }
16 __builtin_return_address (2), // { dg-warning "builtin_return_address" }
17 __builtin_return_address (3), // { dg-warning "builtin_return_address" }
18 __builtin_return_address (4) // { dg-warning "builtin_return_address" }
19 };
20
21
22 void* __attribute__ ((noclone, noinline))
test_builtin_frame_address(unsigned i)23 test_builtin_frame_address (unsigned i)
24 {
25 void* const fa[] = {
26 __builtin_frame_address (0),
27 __builtin_frame_address (1), // { dg-warning "builtin_frame_address" }
28 __builtin_frame_address (2), // { dg-warning "builtin_frame_address" }
29 __builtin_frame_address (3), // { dg-warning "builtin_frame_address" }
30 __builtin_frame_address (4) // { dg-warning "builtin_frame_address" }
31 };
32
33 return fa [i];
34 }
35
36
37 void* __attribute__ ((noclone, noinline))
test_builtin_return_address(unsigned i)38 test_builtin_return_address (unsigned i)
39 {
40 void* const ra[] = {
41 __builtin_return_address (0),
42 __builtin_return_address (1), // { dg-warning "builtin_return_address" }
43 __builtin_return_address (2), // { dg-warning "builtin_return_address" }
44 __builtin_return_address (3), // { dg-warning "builtin_return_address" }
45 __builtin_return_address (4) // { dg-warning "builtin_return_address" }
46 };
47 return ra [i];
48 }
49
50
main()51 int main ()
52 {
53 test_builtin_frame_address (0);
54
55 test_builtin_return_address (0);
56
57 void* const a[] = {
58 __builtin_frame_address (0),
59 __builtin_frame_address (1), // { dg-warning "builtin_frame_address" }
60 __builtin_frame_address (2), // { dg-warning "builtin_frame_address" }
61 __builtin_frame_address (3), // { dg-warning "builtin_frame_address" }
62 __builtin_frame_address (4), // { dg-warning "builtin_frame_address" }
63
64 __builtin_return_address (0),
65 __builtin_return_address (1), // { dg-warning "builtin_return_address" }
66 __builtin_return_address (2), // { dg-warning "builtin_return_address" }
67 __builtin_return_address (3), // { dg-warning "builtin_return_address" }
68 __builtin_return_address (4) // { dg-warning "builtin_return_address" }
69 };
70 }
71