summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-18 13:58:08 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2008-04-18 13:58:08 +0000
commit924bbf0237ffce7bd66e35cba2afbbe96bea0202 (patch)
tree7a2e1b1d5ba3460de2699e7cd1bc2b1739fc3119 /gcc/testsuite
parent83a50aef528bed2048382a81f25ae05a71378794 (diff)
downloadgcc-924bbf0237ffce7bd66e35cba2afbbe96bea0202.tar.gz
libcpp/ChangeLog:
2008-04-14 Kris Van Hees <kris.van.hees@oracle.com> * include/cpp-id-data.h (UC): Was U, conflicts with U... literal. * include/cpplib.h (CHAR16, CHAR32, STRING16, STRING32): New tokens. (struct cpp_options): Added uliterals. (cpp_interpret_string): Update prototype. (cpp_interpret_string_notranslate): Idem. * charset.c (init_iconv_desc): New width member in cset_converter. (cpp_init_iconv): Add support for char{16,32}_cset_desc. (convert_ucn): Idem. (emit_numeric_escape): Idem. (convert_hex): Idem. (convert_oct): Idem. (convert_escape): Idem. (converter_for_type): New function. (cpp_interpret_string): Use converter_for_type, support u and U prefix. (cpp_interpret_string_notranslate): Match changed prototype. (wide_str_to_charconst): Use converter_for_type. (cpp_interpret_charconst): Add support for CPP_CHAR{16,32}. * directives.c (linemarker_dir): Macro U changed to UC. (parse_include): Idem. (register_pragma_1): Idem. (restore_registered_pragmas): Idem. (get__Pragma_string): Support CPP_STRING{16,32}. * expr.c (eval_token): Support CPP_CHAR{16,32}. * init.c (struct lang_flags): Added uliterals. (lang_defaults): Idem. * internal.h (struct cset_converter) <width>: New field. (struct cpp_reader) <char16_cset_desc>: Idem. (struct cpp_reader) <char32_cset_desc>: Idem. * lex.c (digraph_spellings): Macro U changed to UC. (OP, TK): Idem. (lex_string): Add support for u'...', U'...', u... and U.... (_cpp_lex_direct): Idem. * macro.c (_cpp_builtin_macro_text): Macro U changed to UC. (stringify_arg): Support CPP_CHAR{16,32} and CPP_STRING{16,32}. gcc/ChangeLog: 2008-04-14 Kris Van Hees <kris.van.hees@oracle.com> * c-common.c (CHAR16_TYPE, CHAR32_TYPE): New macros. (fname_as_string): Match updated cpp_interpret_string prototype. (fix_string_type): Support char16_t* and char32_t*. (c_common_nodes_and_builtins): Add char16_t and char32_t (and derivative) nodes. Register as builtin if C++0x. (c_parse_error): Support CPP_CHAR{16,32}. * c-common.h (RID_CHAR16, RID_CHAR32): New elements. (enum c_tree_index) <CTI_CHAR16_TYPE, CTI_SIGNED_CHAR16_TYPE, CTI_UNSIGNED_CHAR16_TYPE, CTI_CHAR32_TYPE, CTI_SIGNED_CHAR32_TYPE, CTI_UNSIGNED_CHAR32_TYPE, CTI_CHAR16_ARRAY_TYPE, CTI_CHAR32_ARRAY_TYPE>: New elements. (char16_type_node, signed_char16_type_node, unsigned_char16_type_node, char32_type_node, signed_char32_type_node, char16_array_type_node, char32_array_type_node): New defines. * c-lex.c (cb_ident): Match updated cpp_interpret_string prototype. (c_lex_with_flags): Support CPP_CHAR{16,32} and CPP_STRING{16,32}. (lex_string): Support CPP_STRING{16,32}, match updated cpp_interpret_string and cpp_interpret_string_notranslate prototypes. (lex_charconst): Support CPP_CHAR{16,32}. * c-parser.c (c_parser_postfix_expression): Support CPP_CHAR{16,32} and CPP_STRING{16,32}. gcc/cp/ChangeLog: 2008-04-14 Kris Van Hees <kris.van.hees@oracle.com> * cvt.c (type_promotes_to): Support char16_t and char32_t. * decl.c (grokdeclarator): Disallow signed/unsigned/short/long on char16_t and char32_t. * lex.c (reswords): Add char16_t and char32_t (for c++0x). * mangle.c (write_builtin_type): Mangle char16_t/char32_t as vendor extended builtin type u8char32_t. * parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Support RID_CHAR{16,32}. (cp_lexer_print_token): Support CPP_STRING{16,32}. (cp_parser_is_string_literal): Idem. (cp_parser_string_literal): Idem. (cp_parser_primary_expression): Support CPP_CHAR{16,32} and CPP_STRING{16,32}. (cp_parser_simple_type_specifier): Support RID_CHAR{16,32}. * tree.c (char_type_p): Support char16_t and char32_t as char types. * typeck.c (string_conv_p): Support char16_t and char32_t. gcc/testsuite/ChangeLog: 2008-04-14 Kris Van Hees <kris.van.hees@oracle.com> Tests for char16_t and char32_t support. * g++.dg/ext/utf-cvt.C: New * g++.dg/ext/utf-cxx0x.C: New * g++.dg/ext/utf-cxx98.C: New * g++.dg/ext/utf-dflt.C: New * g++.dg/ext/utf-gnuxx0x.C: New * g++.dg/ext/utf-gnuxx98.C: New * g++.dg/ext/utf-mangle.C: New * g++.dg/ext/utf-typedef-cxx0x.C: New * g++.dg/ext/utf-typedef- * g++.dg/ext/utf-typespec.C: New * g++.dg/ext/utf16-1.C: New * g++.dg/ext/utf16-2.C: New * g++.dg/ext/utf16-3.C: New * g++.dg/ext/utf16-4.C: New * g++.dg/ext/utf32-1.C: New * g++.dg/ext/utf32-2.C: New * g++.dg/ext/utf32-3.C: New * g++.dg/ext/utf32-4.C: New * gcc.dg/utf-cvt.c: New * gcc.dg/utf-dflt.c: New * gcc.dg/utf16-1.c: New * gcc.dg/utf16-2.c: New * gcc.dg/utf16-3.c: New * gcc.dg/utf16-4.c: New * gcc.dg/utf32-1.c: New * gcc.dg/utf32-2.c: New * gcc.dg/utf32-3.c: New * gcc.dg/utf32-4.c: New libiberty/ChangeLog: 2008-04-14 Kris Van Hees <kris.van.hees@oracle.com> * testsuite/demangle-expected: Added tests for char16_t and char32_t. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134438 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog32
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-badconcat.C22
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-cvt.C46
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-cxx0x.C14
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-cxx98.C29
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-dflt.C29
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-gnuxx0x.C14
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-gnuxx98.C29
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-mangle.C14
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-typedef-cxx0x.C7
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-typedef-cxx98.C7
-rw-r--r--gcc/testsuite/g++.dg/ext/utf-typespec.C25
-rw-r--r--gcc/testsuite/g++.dg/ext/utf16-1.C65
-rw-r--r--gcc/testsuite/g++.dg/ext/utf16-2.C30
-rw-r--r--gcc/testsuite/g++.dg/ext/utf16-3.C47
-rw-r--r--gcc/testsuite/g++.dg/ext/utf16-4.C18
-rw-r--r--gcc/testsuite/g++.dg/ext/utf32-1.C42
-rw-r--r--gcc/testsuite/g++.dg/ext/utf32-2.C29
-rw-r--r--gcc/testsuite/g++.dg/ext/utf32-3.C46
-rw-r--r--gcc/testsuite/g++.dg/ext/utf32-4.C18
-rw-r--r--gcc/testsuite/gcc.dg/utf-badconcat.c22
-rw-r--r--gcc/testsuite/gcc.dg/utf-cvt.c49
-rw-r--r--gcc/testsuite/gcc.dg/utf-dflt.c25
-rw-r--r--gcc/testsuite/gcc.dg/utf16-1.c67
-rw-r--r--gcc/testsuite/gcc.dg/utf16-2.c32
-rw-r--r--gcc/testsuite/gcc.dg/utf16-3.c49
-rw-r--r--gcc/testsuite/gcc.dg/utf16-4.c20
-rw-r--r--gcc/testsuite/gcc.dg/utf32-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/utf32-2.c31
-rw-r--r--gcc/testsuite/gcc.dg/utf32-3.c48
-rw-r--r--gcc/testsuite/gcc.dg/utf32-4.c20
31 files changed, 970 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 339ac3adee6..e839cde8630 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,35 @@
+2008-04-18 Kris Van Hees <kris.van.hees@oracle.com>
+
+ Tests for char16_t and char32_t support.
+ * g++.dg/ext/utf-cvt.C: New
+ * g++.dg/ext/utf-cxx0x.C: New
+ * g++.dg/ext/utf-cxx98.C: New
+ * g++.dg/ext/utf-dflt.C: New
+ * g++.dg/ext/utf-gnuxx0x.C: New
+ * g++.dg/ext/utf-gnuxx98.C: New
+ * g++.dg/ext/utf-mangle.C: New
+ * g++.dg/ext/utf-typedef-cxx0x.C: New
+ * g++.dg/ext/utf-typedef-cxx98.C: New
+ * g++.dg/ext/utf-typespec.C: New
+ * g++.dg/ext/utf16-1.C: New
+ * g++.dg/ext/utf16-2.C: New
+ * g++.dg/ext/utf16-3.C: New
+ * g++.dg/ext/utf16-4.C: New
+ * g++.dg/ext/utf32-1.C: New
+ * g++.dg/ext/utf32-2.C: New
+ * g++.dg/ext/utf32-3.C: New
+ * g++.dg/ext/utf32-4.C: New
+ * gcc.dg/utf-cvt.c: New
+ * gcc.dg/utf-dflt.c: New
+ * gcc.dg/utf16-1.c: New
+ * gcc.dg/utf16-2.c: New
+ * gcc.dg/utf16-3.c: New
+ * gcc.dg/utf16-4.c: New
+ * gcc.dg/utf32-1.c: New
+ * gcc.dg/utf32-2.c: New
+ * gcc.dg/utf32-3.c: New
+ * gcc.dg/utf32-4.c: New
+
2008-04-18 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/varsize_return.ads: New test.
diff --git a/gcc/testsuite/g++.dg/ext/utf-badconcat.C b/gcc/testsuite/g++.dg/ext/utf-badconcat.C
new file mode 100644
index 00000000000..bab020e4fe3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/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=c++0x" } */
+
+const void *s0 = u"a" "b";
+const void *s1 = "a" u"b";
+const void *s2 = u"a" U"b"; /* { dg-error "non-standard concatenation" } */
+const void *s3 = U"a" u"b"; /* { dg-error "non-standard concatenation" } */
+const void *s4 = u"a" L"b"; /* { dg-error "non-standard concatenation" } */
+const void *s5 = L"a" u"b"; /* { dg-error "non-standard concatenation" } */
+const void *s6 = u"a" u"b";
+const void *s7 = U"a" "b";
+const void *s8 = "a" U"b";
+const void *s9 = U"a" L"b"; /* { dg-error "non-standard concatenation" } */
+const void *sa = L"a" U"b"; /* { dg-error "non-standard concatenation" } */
+const void *sb = U"a" U"b";
+const void *sc = L"a" "b";
+const void *sd = "a" L"b";
+const void *se = L"a" L"b";
+
+int main () {}
diff --git a/gcc/testsuite/g++.dg/ext/utf-cvt.C b/gcc/testsuite/g++.dg/ext/utf-cvt.C
new file mode 100644
index 00000000000..0e6b17a5ad1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-cvt.C
@@ -0,0 +1,46 @@
+/* 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=c++0x -Wall -Wconversion -Wsign-conversion -Wsign-promo" } */
+
+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/g++.dg/ext/utf-cxx0x.C b/gcc/testsuite/g++.dg/ext/utf-cxx0x.C
new file mode 100644
index 00000000000..1daa0dee487
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-cxx0x.C
@@ -0,0 +1,14 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test parsing of u and U prefixes when also used as macros. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+#define u L
+#define U L
+
+const unsigned short c2 = u'a';
+const unsigned long c3 = U'a';
+const void *s0 = u"a";
+const void *s1 = U"a";
+
+int main () {}
diff --git a/gcc/testsuite/g++.dg/ext/utf-cxx98.C b/gcc/testsuite/g++.dg/ext/utf-cxx98.C
new file mode 100644
index 00000000000..a8dd13a4e34
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-cxx98.C
@@ -0,0 +1,29 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t in c++98. */
+/* Ensure u and U prefixes are parsed as separate tokens in c++98. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++98" } */
+
+const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
+const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
+
+const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
+const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
+
+#define u 1 +
+#define U 2 +
+
+const unsigned short c5 = u'a';
+const unsigned long c6 = 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/g++.dg/ext/utf-dflt.C b/gcc/testsuite/g++.dg/ext/utf-dflt.C
new file mode 100644
index 00000000000..942f2b26d38
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-dflt.C
@@ -0,0 +1,29 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t in default std. */
+/* Ensure u and U prefixes are parsed as separate tokens in default std. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
+const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
+
+const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
+const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
+
+#define u 1 +
+#define U 2 +
+
+const unsigned short c4 = u'a';
+const unsigned long c5 = 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/g++.dg/ext/utf-gnuxx0x.C b/gcc/testsuite/g++.dg/ext/utf-gnuxx0x.C
new file mode 100644
index 00000000000..0a6967fe40d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-gnuxx0x.C
@@ -0,0 +1,14 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test parsing of u and U prefixes when also used as macros. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu++0x" } */
+
+#define u L
+#define U L
+
+const unsigned short c2 = u'a';
+const unsigned long c3 = U'a';
+const void *s0 = u"a";
+const void *s1 = U"a";
+
+int main () {}
diff --git a/gcc/testsuite/g++.dg/ext/utf-gnuxx98.C b/gcc/testsuite/g++.dg/ext/utf-gnuxx98.C
new file mode 100644
index 00000000000..fc8068b7e99
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-gnuxx98.C
@@ -0,0 +1,29 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t in gnu++98. */
+/* Ensure u and U prefixes are parsed as separate tokens in gnu++98. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu++98" } */
+
+const static char16_t c0 = 'a'; /* { dg-error "not name a type" } */
+const static char32_t c1 = 'a'; /* { dg-error "not name a type" } */
+
+const unsigned short c2 = u'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } */
+const unsigned long c3 = U'a'; /* { dg-error "not declared" } */
+ /* { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } */
+
+#define u 1 +
+#define U 2 +
+
+const unsigned short c5 = u'a';
+const unsigned long c6 = 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/g++.dg/ext/utf-mangle.C b/gcc/testsuite/g++.dg/ext/utf-mangle.C
new file mode 100644
index 00000000000..bb5e3822adc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-mangle.C
@@ -0,0 +1,14 @@
+// Contributed by Kris Van Hees <kris.van.hees@oracle.com>
+// Test the support for char16_t character constants.
+// { dg-do compile }
+// { dg-options "-std=c++0x" }
+
+void f0 (char16_t c) {}
+void f1 (char32_t c) {}
+void f2 (char16_t *s) {}
+void f3 (char32_t *s) {}
+
+// { dg-final { scan-assembler "_Z2f0u8char16_t:" } }
+// { dg-final { scan-assembler "_Z2f1u8char32_t:" } }
+// { dg-final { scan-assembler "_Z2f2Pu8char16_t:" } }
+// { dg-final { scan-assembler "_Z2f3Pu8char32_t:" } }
diff --git a/gcc/testsuite/g++.dg/ext/utf-typedef-cxx0x.C b/gcc/testsuite/g++.dg/ext/utf-typedef-cxx0x.C
new file mode 100644
index 00000000000..789d08b9cc2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-typedef-cxx0x.C
@@ -0,0 +1,7 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that a typedef to char16_t/char32_t issues a warning in c++0x. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+typedef short unsigned int char16_t; /* { dg-warning "redeclaration" } */
+typedef unsigned int char32_t; /* { dg-warning "redeclaration" } */
diff --git a/gcc/testsuite/g++.dg/ext/utf-typedef-cxx98.C b/gcc/testsuite/g++.dg/ext/utf-typedef-cxx98.C
new file mode 100644
index 00000000000..8922856c2e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-typedef-cxx98.C
@@ -0,0 +1,7 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that a typedef to char16_t/char32_t is fine in c++98. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++98" } */
+
+typedef short unsigned int char16_t;
+typedef unsigned int char32_t;
diff --git a/gcc/testsuite/g++.dg/ext/utf-typespec.C b/gcc/testsuite/g++.dg/ext/utf-typespec.C
new file mode 100644
index 00000000000..6a4af25598a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf-typespec.C
@@ -0,0 +1,25 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that type specifiers are not allowed for char16_t/char32_t. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+signed char16_t c0; /* { dg-error "signed" } */
+signed char32_t c1; /* { dg-error "signed" } */
+unsigned char16_t c2; /* { dg-error "unsigned" } */
+unsigned char32_t c3; /* { dg-error "unsigned" } */
+
+short char16_t c4; /* { dg-error "short" } */
+long char16_t c5; /* { dg-error "long" } */
+short char32_t c6; /* { dg-error "short" } */
+long char32_t c7; /* { dg-error "long" } */
+
+signed short char16_t c8; /* { dg-error "signed" } */
+signed short char32_t c9; /* { dg-error "signed" } */
+signed long char16_t ca; /* { dg-error "signed" } */
+signed long char32_t cb; /* { dg-error "signed" } */
+unsigned short char16_t cc; /* { dg-error "unsigned" } */
+unsigned short char32_t cd; /* { dg-error "unsigned" } */
+unsigned long char16_t ce; /* { dg-error "unsigned" } */
+unsigned long char32_t cf; /* { dg-error "unsigned" } */
+
+int main () {}
diff --git a/gcc/testsuite/g++.dg/ext/utf16-1.C b/gcc/testsuite/g++.dg/ext/utf16-1.C
new file mode 100644
index 00000000000..fa07de912d5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf16-1.C
@@ -0,0 +1,65 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test the support for char16_t character constants. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char16_t c0 = u'a';
+const static char16_t c1 = u'\0';
+const static char16_t c2 = u'\u0024';
+const static char16_t c3 = u'\u2029';
+const static char16_t c4 = u'\u8010';
+
+const static char16_t c5 = 'a';
+const static char16_t c6 = U'a';
+const static char16_t c7 = U'\u2029';
+const static char16_t c8 = U'\u8010';
+const static char16_t c9 = L'a';
+const static char16_t ca = L'\u2029';
+const static 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/g++.dg/ext/utf16-2.C b/gcc/testsuite/g++.dg/ext/utf16-2.C
new file mode 100644
index 00000000000..d7a6056f81c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf16-2.C
@@ -0,0 +1,30 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test the support for char16_t* string literals. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char16_t *s0 = u"ab";
+const static char16_t *s1 = u"a\u0024";
+const static char16_t *s2 = u"a\u2029";
+const static 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/g++.dg/ext/utf16-3.C b/gcc/testsuite/g++.dg/ext/utf16-3.C
new file mode 100644
index 00000000000..183347b6ee9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf16-3.C
@@ -0,0 +1,47 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test concatenation of char16_t* string literals. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char16_t *s0 = u"a" u"b";
+
+const static char16_t *s1 = u"a" "b";
+const static char16_t *s2 = "a" u"b";
+const static char16_t *s3 = u"a" "\u2029";
+const static char16_t *s4 = "\u2029" u"b";
+const static char16_t *s5 = u"a" "\U00064321";
+const static 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/g++.dg/ext/utf16-4.C b/gcc/testsuite/g++.dg/ext/utf16-4.C
new file mode 100644
index 00000000000..0fb7459c21e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf16-4.C
@@ -0,0 +1,18 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t character constants. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+const static char16_t c0 = u''; /* { dg-error "empty character" } */
+const static char16_t c1 = u'ab'; /* { dg-warning "constant too long" } */
+const static char16_t c2 = u'\U00064321'; /* { dg-warning "constant too long" } */
+
+const static char16_t c3 = 'a';
+const static char16_t c4 = U'a';
+const static char16_t c5 = U'\u2029';
+const static char16_t c6 = U'\U00064321'; /* { dg-warning "implicitly truncated" } */
+const static char16_t c7 = L'a';
+const static char16_t c8 = L'\u2029';
+const static char16_t c9 = L'\U00064321'; /* { dg-warning "implicitly truncated" } */
+
+int main () {}
diff --git a/gcc/testsuite/g++.dg/ext/utf32-1.C b/gcc/testsuite/g++.dg/ext/utf32-1.C
new file mode 100644
index 00000000000..98465a0a1b9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf32-1.C
@@ -0,0 +1,42 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test the support for char32_t character constants. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char32_t c0 = U'a';
+const static char32_t c1 = U'\0';
+const static char32_t c2 = U'\u0024';
+const static char32_t c3 = U'\u2029';
+const static 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/g++.dg/ext/utf32-2.C b/gcc/testsuite/g++.dg/ext/utf32-2.C
new file mode 100644
index 00000000000..e2256ba7464
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf32-2.C
@@ -0,0 +1,29 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test the support for char32_t* string constants. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char32_t *s0 = U"ab";
+const static char32_t *s1 = U"a\u0024";
+const static char32_t *s2 = U"a\u2029";
+const static 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/g++.dg/ext/utf32-3.C b/gcc/testsuite/g++.dg/ext/utf32-3.C
new file mode 100644
index 00000000000..bba893cef5a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf32-3.C
@@ -0,0 +1,46 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test concatenation of char32_t* string literals. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+const static char32_t *s0 = U"a" U"b";
+
+const static char32_t *s1 = U"a" "b";
+const static char32_t *s2 = "a" U"b";
+const static char32_t *s3 = U"a" "\u2029";
+const static char32_t *s4 = "\u2029" U"b";
+const static char32_t *s5 = U"a" "\U00064321";
+const static 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/g++.dg/ext/utf32-4.C b/gcc/testsuite/g++.dg/ext/utf32-4.C
new file mode 100644
index 00000000000..af2fa8db1b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/utf32-4.C
@@ -0,0 +1,18 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char32_t character constants. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+const static char32_t c0 = U''; /* { dg-error "empty character" } */
+const static char32_t c1 = U'ab'; /* { dg-warning "constant too long" } */
+const static char32_t c2 = U'\U00064321';
+
+const static char32_t c3 = 'a';
+const static char32_t c4 = u'a';
+const static char32_t c5 = u'\u2029';
+const static char32_t c6 = u'\U00064321'; /* { dg-warning "constant too long" } */
+const static char32_t c7 = L'a';
+const static char32_t c8 = L'\u2029';
+const static char32_t c9 = L'\U00064321';
+
+int main () {}
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 () {}