OSDN Git Service

* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cpp / charconst-3.c
1 /* Copyright (C) 2001 Free Software Foundation, Inc.  */
2
3 /* { dg-do run } */
4 /* { dg-options -Wno-multichar } */
5
6 /* This tests values and signedness of multichar charconsts.
7
8    Neil Booth, 5 May 2002.  */
9
10 #include <limits.h>
11
12 int main ()
13 {
14   /* These tests require at least 2-byte ints.  8-)  */
15 #if INT_MAX > 127
16   int scale = (int) (unsigned char) -1 + 1;
17
18   if ('ab' != (int) ((unsigned char) 'a' * scale + (unsigned char) 'b'))
19     abort ();
20
21   if ('\234b' != (int) ((unsigned char) '\234' * scale + (unsigned char) 'b'))
22     abort ();
23
24   if ('b\234' != (int) ((unsigned char) 'b' * scale + (unsigned char) '\234'))
25     abort ();
26   /* Multichar charconsts have type int and should be signed.  */
27 #if INT_MAX == 32767
28 # if '\234a' > 0
29 #  error Preprocessor charconsts 1
30 # endif
31   if ('\234a' > 0)
32     abort ();
33 #elif INT_MAX == 2147483647
34 # if '\234aaa' > 0
35 #  error Preprocessor charconsts 2
36 # endif
37   if ('\234aaa' > 0)
38     abort ();
39 #elif INT_MAX == 9223372036854775807
40 # if '\234aaaaaaa' > 0
41 #  error Preprocessor charconsts 3
42 # endif
43   if ('\234aaaaaaa' > 0)
44     abort ();
45 #endif
46 #endif
47   return 0;
48 }