Debian Codegraph @

gcc/testsuite/c-c++-common/torture/harden-cfr-noret.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fharden-control-flow-redundancy -fhardcfr-check-noreturn-calls=always -fdump-tree-hardcfr -ffat-lto-objects" } */
3
4 /* Check that we insert checking before all noreturn calls. */
5
6 #ifndef ATTR_NOTHROW_OPT /* Overridden in harden-cfr-noret-noexcept. */
7 #define ATTR_NOTHROW_OPT __attribute__ ((__nothrow__))
8 #endif
9
10 extern void __attribute__ ((__noreturn__)) ATTR_NOTHROW_OPT g (void);
11
12 void f(int i) {
13 if (i)
14 /* Out-of-line checks here... */
15 g ();
16 /* ... and here. */
17 }
18
19 void __attribute__ ((__noinline__, __noclone__))
20 h(void) {
21 /* Inline check here. */
22 g ();
23 }
24
25 #ifndef OMIT_H2 /* from harden-cfr-noret-never. */
26 void h2(void) {
27 /* Inline check either here, whether because of noreturn or tail call... */
28 h ();
29 /* ... or here, if not optimizing. */
30 }
31 #endif
32
33 /* One out-of-line check before the noreturn call in f, and another at the end
34 of f. */
35 /* { dg-final { scan-tree-dump-times "hardcfr_check" 2 "hardcfr" } } */
36 /* One inline check in h, before the noreturn call, and another in h2, before
37 or after the call, depending on noreturn detection. */
38 /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "hardcfr" } } */