OSDN Git Service

Index: gcc/ChangeLog
[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 extern void abort (void);
13
14 int main ()
15 {
16   /* These tests require at least 2-byte ints.  8-)  */
17 #if INT_MAX > 127
18   int scale = (int) (unsigned char) -1 + 1;
19
20   if ('ab' != (int) ((unsigned char) 'a' * scale + (unsigned char) 'b'))
21     abort ();
22
23   if ('\234b' != (int) ((unsigned char) '\234' * scale + (unsigned char) 'b'))
24     abort ();
25
26   if ('b\234' != (int) ((unsigned char) 'b' * scale + (unsigned char) '\234'))
27     abort ();
28   /* Multichar charconsts have type int and should be signed.  */
29 #if INT_MAX == 32767
30 # if '\234a' > 0
31 #  error Preprocessor charconsts 1
32 # endif
33   if ('\234a' > 0)
34     abort ();
35 #elif INT_MAX == 2147483647
36 # if '\234aaa' > 0
37 #  error Preprocessor charconsts 2
38 # endif
39   if ('\234aaa' > 0)
40     abort ();
41 #elif INT_MAX == 9223372036854775807
42 # if '\234aaaaaaa' > 0
43 #  error Preprocessor charconsts 3
44 # endif
45   if ('\234aaaaaaa' > 0)
46     abort ();
47 #endif
48 #endif
49   return 0;
50 }