1 /* { dg-options "-fnon-call-exceptions" } */
2 /* With -fnon-call-exceptions 0 / 0 should not be eliminated. */
3 /* { dg-additional-options "-DSIGNAL_SUPPRESS" { target { ! signal } } } */
7 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)
8 /* On PPC division by zero does not trap. */
10 #elif defined (__riscv)
11 /* On RISC-V division by zero does not trap. */
13 #elif defined (__SPU__)
14 /* On SPU division by zero does not trap. */
16 #elif defined (__sh__)
17 /* On SH division by zero does not trap. */
19 #elif defined (__v850__)
20 /* On V850 division by zero does not trap. */
22 #elif defined (__MSP430__)
23 /* On MSP430 division by zero does not trap. */
25 #elif defined (__RL78__)
26 /* On RL78 division by zero does not trap. */
28 #elif defined (__RX__)
29 /* On RX division by zero does not trap. */
31 #elif defined (__aarch64__)
32 /* On AArch64 integer division by zero does not trap. */
34 #elif defined (__TMS320C6X__)
35 /* On TI C6X division by zero does not trap. */
37 #elif defined (__VISIUM__)
38 /* On Visium division by zero does not trap. */
40 #elif defined (__mips__) && !defined(__linux__)
41 /* MIPS divisions do trap by default, but libgloss targets do not
42 intercept the trap and raise a SIGFPE. The same is probably
43 true of other bare-metal environments, so restrict the test to
44 systems that use the Linux kernel. */
46 #elif defined (__mips16) && defined(__linux__)
47 /* Not all Linux kernels deal correctly the breakpoints generated by
48 MIPS16 divisions by zero. They show up as a SIGTRAP instead. */
50 #elif defined (__MICROBLAZE__)
51 /* We cannot rely on division by zero generating a trap. */
53 #elif defined (__epiphany__)
54 /* Epiphany does not have hardware division, and the software implementation
55 has truly undefined behavior for division by 0. */
57 #elif defined (__m68k__) && !defined(__linux__)
58 /* Attempting to trap division-by-zero in this way isn't likely to work on
59 bare-metal m68k systems. */
61 #elif defined (__CRIS__)
62 /* No SIGFPE for CRIS integer division. */
64 #elif defined (__MMIX__)
65 /* By default we emit a sequence with DIVU, which "never signals an
66 exceptional condition, even when dividing by zero". */
68 #elif defined (__arc__)
69 /* No SIGFPE for ARC integer division. */
71 #elif defined (__arm__) && defined (__ARM_EABI__)
72 # ifdef __ARM_ARCH_EXT_IDIV__
73 /* Hardware division instructions may not trap, and handle trapping
74 differently anyway. Skip the test if we have those instructions. */
78 /* ARM division-by-zero behavior is to call a helper function, which
79 can do several different things, depending on requirements. Emulate
80 the behavior of other targets here by raising SIGFPE. */
81 int __attribute__((used
))
82 __aeabi_idiv0 (int return_value
)
89 #elif defined (__nios2__)
90 /* Nios II requires both hardware support and user configuration to
91 raise an exception on divide by zero. */
93 #elif defined (__nvptx__)
94 /* There isn't even a signal function. */
96 #elif defined (__csky__)
97 /* This presently doesn't raise SIGFPE even on csky-linux-gnu, much
98 less bare metal. See the implementation of __divsi3 in libgcc. */
104 extern void abort (void);
105 extern void exit (int);
112 sigfpe (int signum
__attribute__ ((unused
)))
119 /* When optimizing, the compiler is smart enough to constant fold the
120 static unset variables i and j to produce 0 / 0, but it can't
121 eliminate the assignment to the global k. */
124 int k
__attribute__ ((used
));
130 signal (SIGFPE
, sigfpe
);