diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/utf-badconcat.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf-cvt.c | 49 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf-dflt.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf16-1.c | 67 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf16-2.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf16-3.c | 49 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf16-4.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf32-1.c | 44 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf32-2.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf32-3.c | 48 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/utf32-4.c | 20 |
11 files changed, 407 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/utf-badconcat.c b/gcc/testsuite/gcc.dg/utf-badconcat.c new file mode 100644 index 00000000000..61ce495ed3d --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf-badconcat.c @@ -0,0 +1,22 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test unsupported concatenation of char16_t/char32_t* string literals. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void *s0 = u"a" "b"; +void *s1 = "a" u"b"; +void *s2 = u"a" U"b"; /* { dg-error "non-standard concatenation" } */ +void *s3 = U"a" u"b"; /* { dg-error "non-standard concatenation" } */ +void *s4 = u"a" L"b"; /* { dg-error "non-standard concatenation" } */ +void *s5 = L"a" u"b"; /* { dg-error "non-standard concatenation" } */ +void *s6 = u"a" u"b"; +void *s7 = U"a" "b"; +void *s8 = "a" U"b"; +void *s9 = U"a" L"b"; /* { dg-error "non-standard concatenation" } */ +void *sa = L"a" U"b"; /* { dg-error "non-standard concatenation" } */ +void *sb = U"a" U"b"; +void *sc = L"a" "b"; +void *sd = "a" L"b"; +void *se = L"a" L"b"; + +int main () {} diff --git a/gcc/testsuite/gcc.dg/utf-cvt.c b/gcc/testsuite/gcc.dg/utf-cvt.c new file mode 100644 index 00000000000..e4bc624ac35 --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf-cvt.c @@ -0,0 +1,49 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test the char16_t and char32_t promotion rules. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -Wall -Wconversion -Wsign-conversion" } */ + +typedef unsigned short char16_t; +typedef unsigned int char32_t; + +extern void f_c (char); +extern void fsc (signed char); +extern void fuc (unsigned char); +extern void f_s (short); +extern void fss (signed short); +extern void fus (unsigned short); +extern void f_i (int); +extern void fsi (signed int); +extern void fui (unsigned int); +extern void f_l (long); +extern void fsl (signed long); +extern void ful (unsigned long); + +void m (char16_t c0, char32_t c1) +{ + f_c (c0); /* { dg-warning "alter its value" } */ + fsc (c0); /* { dg-warning "alter its value" } */ + fuc (c0); /* { dg-warning "alter its value" } */ + f_s (c0); /* { dg-warning "change the sign" } */ + fss (c0); /* { dg-warning "change the sign" } */ + fus (c0); + f_i (c0); + fsi (c0); + fui (c0); + f_l (c0); + fsl (c0); + ful (c0); + + f_c (c1); /* { dg-warning "alter its value" } */ + fsc (c1); /* { dg-warning "alter its value" } */ + fuc (c1); /* { dg-warning "alter its value" } */ + f_s (c1); /* { dg-warning "alter its value" } */ + fss (c1); /* { dg-warning "alter its value" } */ + fus (c1); /* { dg-warning "alter its value" } */ + f_i (c1); /* { dg-warning "change the sign" } */ + fsi (c1); /* { dg-warning "change the sign" } */ + fui (c1); + f_l (c1); /* { dg-warning "change the sign" } */ + fsl (c1); /* { dg-warning "change the sign" } */ + ful (c1); +} diff --git a/gcc/testsuite/gcc.dg/utf-dflt.c b/gcc/testsuite/gcc.dg/utf-dflt.c new file mode 100644 index 00000000000..7281ef3c73e --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf-dflt.c @@ -0,0 +1,25 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* If not gnu99, the u and U prefixes should be parsed as separate tokens. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +const unsigned short c0 = u'a'; /* { dg-error "undeclared" } */ + /* { dg-error "expected ',' or ';'" "" { target *-*-* } 6 } */ +const unsigned long c1 = U'a'; /* { dg-error "undeclared" } */ + /* { dg-error "expected ',' or ';'" "" { target *-*-* } 8 } */ + +#define u 1 + +#define U 2 + + +const unsigned short c2 = u'a'; +const unsigned long c3 = U'a'; + +#undef u +#undef U +#define u "a" +#define U "b" + +const void *s0 = u"a"; +const void *s1 = U"a"; + +int main () {} diff --git a/gcc/testsuite/gcc.dg/utf16-1.c b/gcc/testsuite/gcc.dg/utf16-1.c new file mode 100644 index 00000000000..b2c65c0c034 --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf16-1.c @@ -0,0 +1,67 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test the support for char16_t character constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef short unsigned int char16_t; + +extern void abort (void); + +char16_t c0 = u'a'; +char16_t c1 = u'\0'; +char16_t c2 = u'\u0024'; +char16_t c3 = u'\u2029'; +char16_t c4 = u'\u8010'; + +char16_t c5 = 'a'; +char16_t c6 = U'a'; +char16_t c7 = U'\u2029'; +char16_t c8 = U'\u8010'; +char16_t c9 = L'a'; +char16_t ca = L'\u2029'; +char16_t cb = L'\u8010'; + +#define A 0x0061 +#define D 0x0024 +#define X 0x2029 +#define Y 0x8010 + +int main () +{ + if (sizeof (u'a') != sizeof (char16_t)) + abort (); + if (sizeof (u'\0') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u0024') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u2029') != sizeof (char16_t)) + abort (); + if (sizeof (u'\u8010') != sizeof (char16_t)) + abort (); + + if (c0 != A) + abort (); + if (c1 != 0x0000) + abort (); + if (c2 != D) + abort (); + if (c3 != X) + abort (); + if (c4 != Y) + abort (); + + if (c5 != A) + abort (); + if (c6 != A) + abort (); + if (c7 != X) + abort (); + if (c8 != Y) + abort (); + if (c9 != A) + abort (); + if (ca != X) + abort (); + if (cb != Y) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf16-2.c b/gcc/testsuite/gcc.dg/utf16-2.c new file mode 100644 index 00000000000..ad99a1a7a11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf16-2.c @@ -0,0 +1,32 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test the support for char16_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef short unsigned int char16_t; + +extern void abort (void); + +char16_t *s0 = u"ab"; +char16_t *s1 = u"a\u0024"; +char16_t *s2 = u"a\u2029"; +char16_t *s3 = u"a\U00064321"; + +#define A 0x0061 +#define B 0x0062 +#define D 0x0024 +#define X 0x2029 +#define Y1 0xD950 +#define Y2 0xDF21 + +int main () +{ + if (s0[0] != A || s0[1] != B || s0[2] != 0x0000) + abort (); + if (s1[0] != A || s1[1] != D || s0[2] != 0x0000) + abort (); + if (s2[0] != A || s2[1] != X || s0[2] != 0x0000) + abort (); + if (s3[0] != A || s3[1] != Y1 || s3[2] != Y2 || s3[3] != 0x0000) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf16-3.c b/gcc/testsuite/gcc.dg/utf16-3.c new file mode 100644 index 00000000000..d5e31b205fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf16-3.c @@ -0,0 +1,49 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test concatenation of char16_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef short unsigned int char16_t; + +extern void abort (void); + +char16_t *s0 = u"a" u"b"; + +char16_t *s1 = u"a" "b"; +char16_t *s2 = "a" u"b"; +char16_t *s3 = u"a" "\u2029"; +char16_t *s4 = "\u2029" u"b"; +char16_t *s5 = u"a" "\U00064321"; +char16_t *s6 = "\U00064321" u"b"; + +#define A 0x0061 +#define B 0x0062 +#define X 0x2029 +#define Y1 0xD950 +#define Y2 0xDF21 + +int main () +{ + if (sizeof ((u"a" u"b")[0]) != sizeof (char16_t)) + abort (); + if (sizeof ((u"a" "b")[0]) != sizeof (char16_t)) + abort (); + if (sizeof (( "a" u"b")[0]) != sizeof (char16_t)) + abort (); + + if (s0[0] != A || s0[1] != B || s0[2] != 0x0000) + abort (); + + if (s1[0] != A || s1[1] != B || s1[2] != 0x0000) + abort (); + if (s2[0] != A || s2[1] != B || s2[2] != 0x0000) + abort (); + if (s3[0] != A || s3[1] != X || s3[2] != 0x0000) + abort (); + if (s4[0] != X || s4[1] != B || s4[2] != 0x0000) + abort (); + if (s5[0] != A || s5[1] != Y1 || s5[2] != Y2 || s5[3] != 0x0000) + abort (); + if (s6[0] != Y1 || s6[1] != Y2 || s6[2] != B || s6[3] != 0x0000) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf16-4.c b/gcc/testsuite/gcc.dg/utf16-4.c new file mode 100644 index 00000000000..812c8d2cd4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf16-4.c @@ -0,0 +1,20 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Expected errors for char16_t character constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef short unsigned int char16_t; + +char16_t c0 = u''; /* { dg-error "empty character" } */ +char16_t c1 = u'ab'; /* { dg-warning "constant too long" } */ +char16_t c2 = u'\U00064321'; /* { dg-warning "constant too long" } */ + +char16_t c3 = 'a'; +char16_t c4 = U'a'; +char16_t c5 = U'\u2029'; +char16_t c6 = U'\U00064321'; /* { dg-warning "implicitly truncated" } */ +char16_t c7 = L'a'; +char16_t c8 = L'\u2029'; +char16_t c9 = L'\U00064321'; /* { dg-warning "implicitly truncated" } */ + +int main () {} diff --git a/gcc/testsuite/gcc.dg/utf32-1.c b/gcc/testsuite/gcc.dg/utf32-1.c new file mode 100644 index 00000000000..1807d57f6ab --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf32-1.c @@ -0,0 +1,44 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test the support for char32_t character constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef unsigned int char32_t; + +extern void abort (void); + +char32_t c0 = U'a'; +char32_t c1 = U'\0'; +char32_t c2 = U'\u0024'; +char32_t c3 = U'\u2029'; +char32_t c4 = U'\U00064321'; + +#define A 0x00000061 +#define D 0x00000024 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (sizeof (U'a') != sizeof (char32_t)) + abort (); + if (sizeof (U'\0') != sizeof (char32_t)) + abort (); + if (sizeof (U'\u0024') != sizeof (char32_t)) + abort (); + if (sizeof (U'\u2029') != sizeof (char32_t)) + abort (); + if (sizeof (U'\U00064321') != sizeof (char32_t)) + abort (); + + if (c0 != A) + abort (); + if (c1 != 0x0000) + abort (); + if (c2 != D) + abort (); + if (c3 != X) + abort (); + if (c4 != Y) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf32-2.c b/gcc/testsuite/gcc.dg/utf32-2.c new file mode 100644 index 00000000000..820eb8c41ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf32-2.c @@ -0,0 +1,31 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test the support for char32_t* string constants. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef unsigned int char32_t; + +extern void abort (void); + +char32_t *s0 = U"ab"; +char32_t *s1 = U"a\u0024"; +char32_t *s2 = U"a\u2029"; +char32_t *s3 = U"a\U00064321"; + +#define A 0x00000061 +#define B 0x00000062 +#define D 0x00000024 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (s0[0] != A || s0[1] != B || s0[2] != 0x00000000) + abort (); + if (s1[0] != A || s1[1] != D || s0[2] != 0x00000000) + abort (); + if (s2[0] != A || s2[1] != X || s0[2] != 0x00000000) + abort (); + if (s3[0] != A || s3[1] != Y || s3[2] != 0x00000000) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf32-3.c b/gcc/testsuite/gcc.dg/utf32-3.c new file mode 100644 index 00000000000..20cbc78e5f5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf32-3.c @@ -0,0 +1,48 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Test concatenation of char32_t* string literals. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -Wall -Werror" } */ + +typedef unsigned int char32_t; + +extern void abort (void); + +char32_t *s0 = U"a" U"b"; + +char32_t *s1 = U"a" "b"; +char32_t *s2 = "a" U"b"; +char32_t *s3 = U"a" "\u2029"; +char32_t *s4 = "\u2029" U"b"; +char32_t *s5 = U"a" "\U00064321"; +char32_t *s6 = "\U00064321" U"b"; + +#define A 0x00000061 +#define B 0x00000062 +#define X 0x00002029 +#define Y 0x00064321 + +int main () +{ + if (sizeof ((U"a" U"b")[0]) != sizeof (char32_t)) + abort (); + if (sizeof ((U"a" "b")[0]) != sizeof (char32_t)) + abort (); + if (sizeof (( "a" U"b")[0]) != sizeof (char32_t)) + abort (); + + if (s0[0] != A || s0[1] != B || s0[2] != 0x00000000) + abort (); + + if (s1[0] != A || s1[1] != B || s1[2] != 0x00000000) + abort (); + if (s2[0] != A || s2[1] != B || s2[2] != 0x00000000) + abort (); + if (s3[0] != A || s3[1] != X || s3[2] != 0x00000000) + abort (); + if (s4[0] != X || s4[1] != B || s4[2] != 0x00000000) + abort (); + if (s5[0] != A || s5[1] != Y || s5[2] != 0x00000000) + abort (); + if (s6[0] != Y || s6[1] != B || s6[2] != 0x00000000) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/utf32-4.c b/gcc/testsuite/gcc.dg/utf32-4.c new file mode 100644 index 00000000000..dd05a9a6c39 --- /dev/null +++ b/gcc/testsuite/gcc.dg/utf32-4.c @@ -0,0 +1,20 @@ +/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ +/* Expected errors for char32_t character constants. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +typedef unsigned int char32_t; + +char32_t c0 = U''; /* { dg-error "empty character" } */ +char32_t c1 = U'ab'; /* { dg-warning "constant too long" } */ +char32_t c2 = U'\U00064321'; + +char32_t c3 = 'a'; +char32_t c4 = u'a'; +char32_t c5 = u'\u2029'; +char32_t c6 = u'\U00064321'; /* { dg-warning "constant too long" } */ +char32_t c7 = L'a'; +char32_t c8 = L'\u2029'; +char32_t c9 = L'\U00064321'; + +int main () {} |