PR tree-optimization/33562
[official-gcc.git] / gcc / testsuite / gcc.dg / cpp / charconst-4.c
blobaae33d35eef7004ea5761d697b4b859de870fcd6
1 /* Copyright (C) 2001 Free Software Foundation, Inc. */
3 /* { dg-do run } */
4 /* { dg-options "-Wno-multichar -fsigned-char" } */
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.
12 Neil Booth, 8 May 2002. */
14 #include <limits.h>
16 extern void abort (void);
18 #if INT_MAX == 32767
19 # define LONG_CHARCONST '!\234a'
20 # define SHORT_CHARCONST '\234a'
21 # define POS_CHARCONST '\1'
22 #elif INT_MAX == 2147483647
23 # define LONG_CHARCONST '!\234abc'
24 # define SHORT_CHARCONST '\234abc'
25 # define POS_CHARCONST '\234a'
26 #elif INT_MAX == 9223372036854775807
27 # define LONG_CHARCONST '!\234abcdefg'
28 # define SHORT_CHARCONST '\234abcdefg'
29 # define POS_CHARCONST '\234a'
30 #else
31 /* Target int size not handled, do something that won't fail. */
32 # define LONG_CHARCONST '\234a'
33 # define SHORT_CHARCONST '\234a'
34 # define POS_CHARCONST '\1'
35 #endif
37 #if POS_CHARCONST < 0
38 # error Charconst incorrectly sign-extended
39 #endif
41 #if LONG_CHARCONST != SHORT_CHARCONST /* { dg-warning "too long" "" } */
42 # error Overly long charconst truncates wrongly for preprocessor
43 #endif
45 int main ()
47 if (POS_CHARCONST < 0)
48 abort ();
49 if (LONG_CHARCONST != SHORT_CHARCONST) /* { dg-warning "too long" "" } */
50 abort ();
51 return 0;