1 /* Test that stack protection is done on chosen functions. */
3 /* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */
4 /* { dg-options "-O2 -fstack-protector-strong" } */
15 /* Function frame address escaped function call. */
32 struct ArrayStruct as
;
35 /* Function frame contains array. */
41 for (i
= 0; i
< 10; ++i
)
43 aa
.as
.array
[i
] = i
* (i
-1) + i
/ 2;
45 return aa
.as
.array
[5];
48 /* Address computation based on a function frame address. */
58 /* Address cast based on a function frame address. */
63 return goo (g0
<< 2 ? (int *)(3 * (long)(void *)(&a
)) : 0);
66 /* Address cast based on a local array. */
71 return goo ((int *)(array
+ 5));
81 /* Address computaton based on a function frame address.*/
86 return goo (&bb
.one
+ sizeof(int));
89 /* Function frame address escaped via global variable. */
99 /* Check that this covers -fstack-protector. */
104 memcpy ((void *)base
, (const void *)pg0
, 105);
105 return (int)(base
[32]);
108 /* Check that this covers -fstack-protector. */
112 char* p
= __builtin_alloca (100);
113 return goo ((int *)(p
+ 50));
117 global2 (struct BB
* pbb
);
119 /* Address taken on struct. */
125 bb
.one
= global2 (&bb
);
126 for (i
= 0; i
< 10; ++i
)
128 bb
.two
= bb
.one
+ bb
.two
;
129 bb
.three
= bb
.one
+ bb
.two
+ bb
.three
;
134 /* { dg-final { scan-assembler-times "stack_chk_fail" 10 } } */