OSDN Git Service

986ea80f57ede04020c0a7e2c77985d71afc4a9f
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cpp / charconst-4.c
1 /* Copyright (C) 2001 Free Software Foundation, Inc.  */
2
3 /* { dg-do run } */
4 /* { dg-options "-Wno-multichar -fsigned-char" } */
5
6 /* This tests how overly-long multichar charconsts are truncated, and
7    whether "short" multichar charconsts are incorrectly sign extended
8    (regardless of char signedness).  Preprocessor is used so that we
9    have only one place where the too long warning is generated, so
10    that the test works for all targets.
11
12    Neil Booth, 8 May 2002.  */
13
14 #include <limits.h>
15
16 #if INT_MAX == 32767
17 # define LONG_CHARCONST '!\234a'
18 # define SHORT_CHARCONST '\234a'
19 # define POS_CHARCONST '\1'
20 #elif INT_MAX == 2147483647
21 # define LONG_CHARCONST '!\234abc'
22 # define SHORT_CHARCONST '\234abc'
23 # define POS_CHARCONST '\234a'
24 #elif INT_MAX == 9223372036854775807
25 # define LONG_CHARCONST '!\234abcdefg'
26 # define SHORT_CHARCONST '\234abcdefg'
27 # define POS_CHARCONST '\234a'
28 #else
29 /* Target int size not handled, do something that won't fail.  */
30 # define LONG_CHARCONST '\234a'
31 # define SHORT_CHARCONST '\234a'
32 # define POS_CHARCONST '\1'
33 #endif
34
35 #if POS_CHARCONST < 0
36 # error Charconst incorrectly sign-extended
37 #endif
38
39 #if LONG_CHARCONST != SHORT_CHARCONST /* { dg-warning "too long" "" } */
40 # error Overly long charconst truncates wrongly for preprocessor
41 #endif
42
43 int main ()
44 {
45   if (POS_CHARCONST < 0)
46     abort ();
47   if (LONG_CHARCONST != SHORT_CHARCONST)  /* { dg-warning "too long" "" } */
48     abort ();
49   return 0;
50 }