aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2004-12-15 13:30:46 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2004-12-15 12:30:46 +0000
commit0aec601466c206f1d9180e928dc694a59e8a1972 (patch)
treea698a04e69a5f69e0c6f90b595a9fd86164c143d /gcc/testsuite
parentc331bf080274e520ae3ac9238c73625c9981dedc (diff)
downloadgcc-0aec601466c206f1d9180e928dc694a59e8a1972.zip
gcc-0aec601466c206f1d9180e928dc694a59e8a1972.tar.gz
gcc-0aec601466c206f1d9180e928dc694a59e8a1972.tar.bz2
re PR other/18665 (-ftrapv borks up simple integer arithmetic)
PR other/18665 * libgcc-std.ver (GCC_3.4.4): Inherit from GCC_3.4.2. Export __absvti2, __addvti3, __mulvti3, __negvti2 and __subvti3. * libgcc2.c (__addvsi3): Rename to __addvSI3. New version if COMPAT_SIMODE_TRAPPING_ARITHMETIC. (__addvdi3): Rename to __addvDI3. (__subvsi3): Rename to __subvSI3. Use word type for the result. New version if COMPAT_SIMODE_TRAPPING_ARITHMETIC. (__subvdi3): Rename to __subvDI3. (_mulvsi3): Rename to _mulvSI3. New version if COMPAT_SIMODE_TRAPPING_ARITHMETIC. (_mulvdi3): Rename to _mulvDI3. (__negvsi2): Rename to __negvSI2. New version if COMPAT_SIMODE_TRAPPING_ARITHMETIC. (__negvdi2): Rename to __negvDI2. (__absvsi2): Rename to __absvSI2. New version if COMPAT_SIMODE_TRAPPING_ARITHMETIC. (__absvdi2): Rename to __absvDI2. * libgcc2.h (64-bit targets): Define COMPAT_SIMODE_TRAPPING_ARITHMETIC. (__absvSI2, __addvSI3, __subvSI3, __mulvSI3, __negvSI2, __absvDI2, __addvDI3, __subvDI3, __mulvDI3, __negvDI2): Define to the appropriate symbol and declare. (__absvsi2, __addvsi3, __subvsi3, __mulvsi3, __negvsi2): Declare if COMPAT_SIMODE_TRAPPING_ARITHMETIC. From-SVN: r92187
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/ftrapv-2.c107
2 files changed, 111 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 98a3af8..37a59e2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-15 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * gcc.dg/ftrapv-2.c: New test.
+
2004-12-15 Nathan Sidwell <nathan@codesourcery.com>
PR 18981
diff --git a/gcc/testsuite/gcc.dg/ftrapv-2.c b/gcc/testsuite/gcc.dg/ftrapv-2.c
new file mode 100644
index 0000000..de66129b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ftrapv-2.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2004 Free Software Foundation.
+
+ PR other/18665
+ Verify that -ftrapv doesn't produce bogus results
+ on 64-bit platforms.
+
+ Written by Eric Botcazou */
+
+/* { dg-do run } */
+/* { dg-options "-ftrapv" } */
+
+extern void abort(void);
+
+int __attribute__((noinline))
+iabsv(int a)
+{
+ return abs(a);
+}
+
+int __attribute__((noinline))
+iaddv(int a, int b)
+{
+ return a + b;
+}
+
+int __attribute__((noinline))
+isubv(int a, int b)
+{
+ return a - b;
+}
+
+int __attribute__((noinline))
+imulv(int a, int b)
+{
+ return a * b;
+}
+
+int __attribute__((noinline))
+inegv(int a)
+{
+ return -a;
+}
+
+long __attribute__((noinline))
+labsv(long a)
+{
+ return abs(a);
+}
+
+long __attribute__((noinline))
+laddv(long a, long b)
+{
+ return a + b;
+}
+
+long __attribute__((noinline))
+lsubv(long a, long b)
+{
+ return a - b;
+}
+
+long __attribute__((noinline))
+lmulv(long a, long b)
+{
+ return a * b;
+}
+
+long __attribute__((noinline))
+lnegv(long a)
+{
+ return -a;
+}
+
+int main(void)
+{
+ if (iabsv (-1) != 1)
+ abort ();
+
+ if (iaddv (2,-3) != -1)
+ abort ();
+
+ if (isubv (2,3) != -1)
+ abort ();
+
+ if (imulv (-2,3) != -6)
+ abort ();
+
+ if (inegv (-1) != 1)
+ abort ();
+
+ if (labsv (-1L) != 1L)
+ abort ();
+
+ if (laddv (2L,-3L) != -1L)
+ abort ();
+
+ if (lsubv (2L,3L) != -1L)
+ abort ();
+
+ if (lmulv (-2L,3L) != -6L)
+ abort ();
+
+ if (lnegv (-1L) != 1L)
+ abort ();
+
+ return 0;
+}