Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / hwasan / unprotected-allocas-0.c
blob88465155c6d0a72bfef1fdd31c59adaf4db549ce
1 /* { dg-do run } */
2 /* { dg-require-effective-target hwaddress_exec } */
3 /* { dg-additional-options "--param hwasan-instrument-allocas=0 -save-temps" } */
4 /* Only run this test without optimisation. When running with optimisation we
5 use the unprotected-allocas-1.c file that also checks there are no memory
6 tagging calls (since when optimised the only variable on the stack should be
7 the vararray/alloca). */
8 /* { dg-skip-if "" { *-*-* } { "-O1" "-O2" "-O3" } { "" } } */
10 #define alloca __builtin_alloca
11 #define assert(x) if (!(x)) __builtin_abort ()
13 char tag_of (void * x) { return ((unsigned long long)x) >> 56; }
15 int __attribute__ ((noinline))
16 using_alloca (int num)
18 int retval = 0;
19 int *big_array = (int*)alloca (num * sizeof (int));
20 char alloca_tag = tag_of (big_array);
21 assert (alloca_tag == 0);
22 for (int i = 0; i < num; ++i) {
23 retval += big_array[i];
25 return retval;
28 int __attribute__ ((noinline))
29 using_vararray (int num)
31 int retval = 0;
32 int big_array[num];
33 char vararray_tag = tag_of (big_array);
34 assert (vararray_tag == 0);
35 for (int i = 0; i < num; ++i) {
36 retval += big_array[i];
38 return retval;
41 int main()
43 using_alloca (16);
44 using_vararray (12);
45 return 0;