comparison gcc/testsuite/gcc.dg/absu.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1
2 /* { dg-do run } */
3 /* { dg-options "-O0" } */
4
5 #include <limits.h>
6 #define ABS(x) (((x) >= 0) ? (x) : -(x))
7
8 #define DEF_TEST(TYPE) \
9 void foo_##TYPE (signed TYPE x, unsigned TYPE y){ \
10 TYPE t = ABS (x); \
11 if (t != y) \
12 __builtin_abort (); \
13 } \
14
15 DEF_TEST (char);
16 DEF_TEST (short);
17 DEF_TEST (int);
18 DEF_TEST (long);
19
20 int main ()
21 {
22 foo_char (SCHAR_MIN + 1, SCHAR_MAX);
23 foo_char (0, 0);
24 foo_char (-1, 1);
25 foo_char (1, 1);
26 foo_char (SCHAR_MAX, SCHAR_MAX);
27
28 foo_int (-1, 1);
29 foo_int (0, 0);
30 foo_int (INT_MAX, INT_MAX);
31 foo_int (INT_MIN + 1, INT_MAX);
32
33 foo_short (-1, 1);
34 foo_short (0, 0);
35 foo_short (SHRT_MAX, SHRT_MAX);
36 foo_short (SHRT_MIN + 1, SHRT_MAX);
37
38 foo_long (-1, 1);
39 foo_long (0, 0);
40 foo_long (LONG_MAX, LONG_MAX);
41 foo_long (LONG_MIN + 1, LONG_MAX);
42
43 return 0;
44 }
45