OSDN Git Service

2012-01-03 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / utf8-1.c
1 /* { dg-do run } */
2 /* { dg-require-iconv "ISO-8859-2" } */
3 /* { dg-options "-std=gnu99 -fexec-charset=ISO-8859-2" } */
4
5 const char *str1 = "h\u00e1\U0000010Dky ";
6 const char *str2 = "\u010d\u00E1rky\n";
7 const char *str3 = u8"h\u00e1\U0000010Dky ";
8 const char *str4 = u8"\u010d\u00E1rky\n";
9 const char *str5 = "h\u00e1\U0000010Dky " "\u010d\u00E1rky\n";
10 const char *str6 = u8"h\u00e1\U0000010Dky " "\u010d\u00E1rky\n";
11 const char *str7 = "h\u00e1\U0000010Dky " u8"\u010d\u00E1rky\n";
12 #define u8
13 const char *str8 = u8"h\u00e1\U0000010Dky " u8"\u010d\u00E1rky\n";
14
15 const char latin2_1[] = "\x68\xe1\xe8\x6b\x79\x20";
16 const char latin2_2[] = "\xe8\xe1\x72\x6b\x79\n";
17 const char utf8_1[] = "\x68\xc3\xa1\xc4\x8d\x6b\x79\x20";
18 const char utf8_2[] = "\xc4\x8d\xc3\xa1\x72\x6b\x79\n";
19
20 int
21 main (void)
22 {
23   if (__builtin_strcmp (str1, latin2_1) != 0
24       || __builtin_strcmp (str2, latin2_2) != 0
25       || __builtin_strcmp (str3, utf8_1) != 0
26       || __builtin_strcmp (str4, utf8_2) != 0
27       || __builtin_strncmp (str5, latin2_1, sizeof (latin2_1) - 1) != 0
28       || __builtin_strcmp (str5 + sizeof (latin2_1) - 1, latin2_2) != 0
29       || __builtin_strncmp (str6, utf8_1, sizeof (utf8_1) - 1) != 0
30       || __builtin_strcmp (str6 + sizeof (utf8_1) - 1, utf8_2) != 0
31       || __builtin_strncmp (str7, utf8_1, sizeof (utf8_1) - 1) != 0
32       || __builtin_strcmp (str7 + sizeof (utf8_1) - 1, utf8_2) != 0
33       || __builtin_strncmp (str8, utf8_1, sizeof (utf8_1) - 1) != 0
34       || __builtin_strcmp (str8 + sizeof (utf8_1) - 1, utf8_2) != 0)
35     __builtin_abort ();
36   if (sizeof ("a" u8"b"[0]) != 1
37       || sizeof (u8"a" "b"[0]) != 1
38       || sizeof (u8"a" u8"b"[0]) != 1
39       || sizeof ("a" "\u010d") != 3
40       || sizeof ("a" u8"\u010d") != 4
41       || sizeof (u8"a" "\u010d") != 4
42       || sizeof (u8"a" "\u010d") != 4)
43     __builtin_abort ();
44   return 0;
45 }