PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.dg / ftrapv-2.c
blob721bece43647fa67f18eade5b475386386b3d1f8
1 /* Copyright (C) 2004 Free Software Foundation.
3 PR other/18665
4 Verify that -ftrapv doesn't produce bogus results
5 on 64-bit platforms.
7 Written by Eric Botcazou */
9 /* { dg-do run } */
10 /* { dg-options "-ftrapv" } */
11 /* { dg-require-effective-target trapping } */
13 extern void abort(void);
14 extern int abs(int);
15 extern long labs(long);
17 int __attribute__((noinline))
18 iabsv(int a)
20 return abs(a);
23 int __attribute__((noinline))
24 iaddv(int a, int b)
26 return a + b;
29 int __attribute__((noinline))
30 isubv(int a, int b)
32 return a - b;
35 int __attribute__((noinline))
36 imulv(int a, int b)
38 return a * b;
41 int __attribute__((noinline))
42 inegv(int a)
44 return -a;
47 long __attribute__((noinline))
48 labsv(long a)
50 return labs(a);
53 long __attribute__((noinline))
54 laddv(long a, long b)
56 return a + b;
59 long __attribute__((noinline))
60 lsubv(long a, long b)
62 return a - b;
65 long __attribute__((noinline))
66 lmulv(long a, long b)
68 return a * b;
71 long __attribute__((noinline))
72 lnegv(long a)
74 return -a;
77 int main(void)
79 if (iabsv (-1) != 1)
80 abort ();
82 if (iaddv (2,-3) != -1)
83 abort ();
85 if (isubv (2,3) != -1)
86 abort ();
88 if (imulv (-2,3) != -6)
89 abort ();
91 if (inegv (-1) != 1)
92 abort ();
94 if (labsv (-1L) != 1L)
95 abort ();
97 if (laddv (2L,-3L) != -1L)
98 abort ();
100 if (lsubv (2L,3L) != -1L)
101 abort ();
103 if (lmulv (-2L,3L) != -6L)
104 abort ();
106 if (lnegv (-1L) != 1L)
107 abort ();
109 return 0;