1 /* Copyright (C) 2001 Free Software Foundation, Inc.  */
2 
3 /* { dg-do compile } */
4 /* { dg-options "-std=c99" } */
5 
6 /* This tests universal character sequences.
7 
8    Neil Booth, 22 May 2001.
9    Richard Henderson, 3 Apr 2002.  */
10 
11 #include <limits.h>
12 
13 #define unsigned        +0
14 #define int             +0
15 #define char            +1
16 #define short           +2
17 #define long            +3
18 
19 #if !defined(WCHAR_MAX)
20 
21 #if __WCHAR_TYPE__ == 0
22 # define WCHAR_MAX      INT_MAX
23 #elif __WCHAR_TYPE__ == 1
24 # define WCHAR_MAX      CHAR_MAX
25 #elif __WCHAR_TYPE__ == 2
26 # define WCHAR_MAX      SHRT_MAX
27 #elif __WCHAR_TYPE__ == 3
28 # define WCHAR_MAX      LONG_MAX
29 #else
30 # error wacky wchar_t
31 #endif
32 
33 #endif
34 
35 #undef unsigned
36 #undef int
37 #undef char
38 #undef short
39 #undef long
40 
41 #if L'\u1234' != 0x1234
42 #error bad short ucs	/* { dg-bogus "bad" "bad u1234 evaluation" } */
43 #endif
44 
45 #if WCHAR_MAX >= 0x7ffffff
46 # if L'\U1234abcd' != 0x1234abcd /* { dg-warning "outside" "" { xfail powerpc-ibm-aix* } } */
47 #  error bad long ucs	/* { dg-bogus "bad" "bad U1234abcd evaluation" } */
48 # endif
49 #endif
50 
foo()51 void foo ()
52 {
53   int c;
54 
55   c = L'\ubad';		/* { dg-error "incomplete" "incomplete UCN 1" } */
56   c = L"\U1234"[0];	/* { dg-error "incomplete" "incomplete UCN 2" } */
57 
58   c = L'\u000x';	/* { dg-error "incomplete" "non-hex digit in UCN" } */
59   /* If sizeof(HOST_WIDE_INT) > sizeof(wchar_t), we can get a multi-character
60      constant warning even for wide characters.  */
61   /* { dg-warning "too long|multi-character" "" { target *-*-* } .-3 } */
62 
63   c = '\u0024';		/* { dg-bogus "invalid" "0024 is a valid UCN" } */
64   c = "\u0040"[0];	/* { dg-bogus "invalid" "0040 is a valid UCN" } */
65   c = L'\u00a0';	/* { dg-bogus "invalid" "00a0 is a valid UCN" } */
66   c = '\U00000060';	/* { dg-bogus "invalid" "0060 is a valid UCN" } */
67 
68   c = '\u0025';		/* { dg-error "not a valid" "0025 invalid UCN" } */
69   c = L"\uD800"[0];	/* { dg-error "not a valid" "D800 invalid UCN" } */
70   c = L'\U0000DFFF';	/* { dg-error "not a valid" "DFFF invalid UCN" } */
71 
72   c = L'\U00110000';	/* { dg-warning "outside|Invalid" "110000 outside UCS" } */
73 }
74