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