summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-23 16:18:32 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-23 16:18:32 +0000
commit47d397e1369479523eaecd1a6b35d610dbd9da96 (patch)
treecf7659287d28d44a74afdea7975d98bd017ddb0d /gcc/testsuite/gcc.c-torture
parentf8d7ed518f97e7d95e702bc58289b0bcb9cb4ac8 (diff)
downloadgcc-47d397e1369479523eaecd1a6b35d610dbd9da96.tar.gz
gcc/:
* tree-vrp.c (extract_range_from_binary_expr): If flag_non_call_exceptions don't eliminate division by zero. * simplify-rtx.c (simplify_binary_operation_1): Likewise. gcc/testsuite/: * gcc.c-torture/execute/20101011-1.c: New test. * gcc.c-torture/execute/20101011-1.x: New test driver. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165884 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20101011-1.c45
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20101011-1.x2
2 files changed, 47 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
new file mode 100644
index 00000000000..4c36ad3e5cf
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -0,0 +1,45 @@
+/* With -fnon-call-exceptions 0 / 0 should not be eliminated. The .x
+ file sets the option. */
+
+#ifdef SIGNAL_SUPPRESS
+# define DO_TEST 0
+#elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)
+ /* On PPC division by zero does not trap. */
+# define DO_TEST 0
+#elif defined (__SPU__)
+ /* On SPU division by zero does not trap. */
+# define DO_TEST 0
+#else
+# define DO_TEST 1
+#endif
+
+#if DO_TEST
+
+#include <signal.h>
+
+void
+sigfpe (int signum __attribute__ ((unused)))
+{
+ exit (0);
+}
+
+#endif
+
+/* When optimizing, the compiler is smart enough to constant fold the
+ static unset variables i and j to produce 0 / 0, but it can't
+ eliminate the assignment to the global k. */
+static int i;
+static int j;
+int k;
+
+int
+main ()
+{
+#ifdef DO_TEST
+ signal (SIGFPE, sigfpe);
+ k = i / j;
+ abort ();
+#else
+ exit (0);
+#endif
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.x b/gcc/testsuite/gcc.c-torture/execute/20101011-1.x
new file mode 100644
index 00000000000..b5c080dd371
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.x
@@ -0,0 +1,2 @@
+set additional_flags "-fnon-call-exceptions"
+return 0