c++: prvalue of array type [PR111286]
[official-gcc.git] / gcc / testsuite / c-c++-common / torture / harden-cfr.c
blob73824c66f50a52e3f203363d72231f4f69c147db
1 /* { dg-do run } */
2 /* { dg-options "-fharden-control-flow-redundancy -fdump-tree-hardcfr --param hardcfr-max-blocks=9 --param hardcfr-max-inline-blocks=5 -ffat-lto-objects" } */
4 /* Check the instrumentation and the parameters. */
6 int
7 f (int i, int j)
9 if (i < j)
10 return 2 * i;
11 else
12 return 3 * j;
15 int
16 g (unsigned i, int j)
18 switch (i)
20 case 0:
21 return j * 2;
23 case 1:
24 return j * 3;
26 case 2:
27 return j * 5;
29 default:
30 return j * 7;
34 int
35 h (unsigned i, int j) /* { dg-warning "has more than 9 blocks, the requested maximum" } */
37 switch (i)
39 case 0:
40 return j * 2;
42 case 1:
43 return j * 3;
45 case 2:
46 return j * 5;
48 case 3:
49 return j * 7;
51 case 4:
52 return j * 11;
54 case 5:
55 return j * 13;
57 case 6:
58 return j * 17;
60 case 7:
61 return j * 19;
63 default:
64 return j * 23;
68 int
69 main (int argc, char *argv[])
71 if (f (1, 2) != 2 || g (2, 5) != 25 || h (4, 3) != 33
72 || argc < 0)
73 __builtin_abort ();
74 /* Call exit, instead of returning, to avoid an edge to the exit block and
75 thus implicitly disable hardening of main, when checking before noreturn
76 calls is disabled. */
77 __builtin_exit (0);
80 /* Inlined checking thus trap for f. */
81 /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "hardcfr" } } */
82 /* Out-of-line checking for g (param), and before both noreturn calls in main. */
83 /* { dg-final { scan-tree-dump-times "__hardcfr_check" 3 "hardcfr" } } */
84 /* No checking for h (too many blocks). */