1 /* { dg-options "-fnon-call-exceptions" } */
2 /* With -fnon-call-exceptions 0 / 0 should not be eliminated. */
6 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)
7 /* On PPC division by zero does not trap. */
9 #elif defined (__riscv)
10 /* On RISC-V division by zero does not trap. */
12 #elif defined (__SPU__)
13 /* On SPU division by zero does not trap. */
15 #elif defined (__sh__)
16 /* On SH division by zero does not trap. */
18 #elif defined (__v850__)
19 /* On V850 division by zero does not trap. */
21 #elif defined (__MSP430__)
22 /* On MSP430 division by zero does not trap. */
24 #elif defined (__RL78__)
25 /* On RL78 division by zero does not trap. */
27 #elif defined (__RX__)
28 /* On RX division by zero does not trap. */
30 #elif defined (__aarch64__)
31 /* On AArch64 integer division by zero does not trap. */
33 #elif defined (__TMS320C6X__)
34 /* On TI C6X division by zero does not trap. */
36 #elif defined (__VISIUM__)
37 /* On Visium division by zero does not trap. */
39 #elif defined (__mips__) && !defined(__linux__)
40 /* MIPS divisions do trap by default, but libgloss targets do not
41 intercept the trap and raise a SIGFPE. The same is probably
42 true of other bare-metal environments, so restrict the test to
43 systems that use the Linux kernel. */
45 #elif defined (__mips16) && defined(__linux__)
46 /* Not all Linux kernels deal correctly the breakpoints generated by
47 MIPS16 divisions by zero. They show up as a SIGTRAP instead. */
49 #elif defined (__MICROBLAZE__)
50 /* We cannot rely on division by zero generating a trap. */
52 #elif defined (__epiphany__)
53 /* Epiphany does not have hardware division, and the software implementation
54 has truly undefined behavior for division by 0. */
56 #elif defined (__m68k__) && !defined(__linux__)
57 /* Attempting to trap division-by-zero in this way isn't likely to work on
58 bare-metal m68k systems. */
60 #elif defined (__CRIS__)
61 /* No SIGFPE for CRIS integer division. */
63 #elif defined (__MMIX__)
64 /* By default we emit a sequence with DIVU, which "never signals an
65 exceptional condition, even when dividing by zero". */
67 #elif defined (__arc__)
68 /* No SIGFPE for ARC integer division. */
70 #elif defined (__arm__) && defined (__ARM_EABI__)
71 # ifdef __ARM_ARCH_EXT_IDIV__
72 /* Hardware division instructions may not trap, and handle trapping
73 differently anyway. Skip the test if we have those instructions. */
77 /* ARM division-by-zero behavior is to call a helper function, which
78 can do several different things, depending on requirements. Emulate
79 the behavior of other targets here by raising SIGFPE. */
80 int __attribute__((used
))
81 __aeabi_idiv0 (int return_value
)
88 #elif defined (__nios2__)
89 /* Nios II requires both hardware support and user configuration to
90 raise an exception on divide by zero. */
92 #elif defined (__nvptx__)
93 /* There isn't even a signal function. */
99 extern void abort (void);
100 extern void exit (int);
107 sigfpe (int signum
__attribute__ ((unused
)))
114 /* When optimizing, the compiler is smart enough to constant fold the
115 static unset variables i and j to produce 0 / 0, but it can't
116 eliminate the assignment to the global k. */
119 int k
__attribute__ ((used
));
125 signal (SIGFPE
, sigfpe
);