c-common.c (c_stddef_cpp_builtins): Define __CHAR16_TYPE__ and __CHAR32_TYPE__.
authorKris Van Hees <kvanhees@gcc.gnu.org>
Fri, 18 Jul 2008 20:23:42 +0000 (20:23 +0000)
committerKris Van Hees <kvanhees@gcc.gnu.org>
Fri, 18 Jul 2008 20:23:42 +0000 (20:23 +0000)
gcc/ChangeLog:
2008-07-16  Kris Van Hees <kris.van.hees@oracle.com>

        * c-common.c (c_stddef_cpp_builtins): Define __CHAR16_TYPE__
        and __CHAR32_TYPE__.
        * c-typeck.c (digest_init): Support char16_t and char32_t.
        (set_nonincremental_init_from_string): Idem.

gcc/cp/ChangeLog:
2008-07-16  Kris Van Hees <kris.van.hees@oracle.com>

        * rtti.c (emit_support_tinfos): Add char16_type_node and
        char32_type_node.
        * typeck2.c (digest_init): Support char16_t and char32_t.

gcc/testsuite/ChangeLog:
2008-07-16  Kris Van Hees <kris.van.hees@oracle.com>

        Tests for char16_t and char32_t support.
        * g++.dg/ext/utf-array.C: New
        * g++.dg/ext/utf-array-short-wchar.C: New
        * g++.dg/ext/utf-rtti.C: New
        * g++.dg/ext/utf-type.c: New
        * gcc.dg/utf-array.c: New
        * gcc.dg/utf-array-short-wchar.c: New
        * gcc.dg/utf-inc-init.c: New
        * gcc.dg/utf-type.c: New

libstdc++-v3/ChangeLog:
2008-07-16  Kris Van Hees <kris.van.hees@oracle.com>
            Holger Hopp <holger.hopp@sap.com>

        * config/abi/pre/gnu.ver: Support char16_t and char32_t.
        * testsuite/util/testsuite_abi.cc (check_version): Add
        CXXABI_1.3.3 to known_versions.

From-SVN: r137965

18 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/rtti.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/utf-array-short-wchar.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf-array.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf-rtti.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf-type.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/utf-array-short-wchar.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/utf-array.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/utf-inc-init.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/utf-type.c [new file with mode: 0644]
libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/testsuite/util/testsuite_abi.cc

index 3c535ef5c4fc6034b411781a782b727cbf61dc29..e074ef6c6cf17be91b8e67a07b91e99eb5e4d23e 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-18  Kris Van Hees  <kris.van.hees@oracle.com>
+
+       * c-common.c (c_stddef_cpp_builtins): Define __CHAR16_TYPE__
+       and __CHAR32_TYPE__.
+       * c-typeck.c (digest_init): Support char16_t and char32_t.
+       (set_nonincremental_init_from_string): Idem.
+
 2008-07-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/36859
index e93d2fba6dffa7ca6a130f623d2db298a993e7d0..cc13e056fd5e9a548f7d4d7a1e60bd4e0eb1e05d 100644 (file)
@@ -4895,6 +4895,8 @@ c_stddef_cpp_builtins(void)
   builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0);
   builtin_define_with_value ("__INTMAX_TYPE__", INTMAX_TYPE, 0);
   builtin_define_with_value ("__UINTMAX_TYPE__", UINTMAX_TYPE, 0);
+  builtin_define_with_value ("__CHAR16_TYPE__", CHAR16_TYPE, 0);
+  builtin_define_with_value ("__CHAR32_TYPE__", CHAR32_TYPE, 0);
 }
 
 static void
index 6b7594e6a260bff6b63e33d6303bd1299bee95a9..dafce2ac23c1d8573b922bf986040f524e2c8614 100644 (file)
@@ -4704,47 +4704,56 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
                         || typ1 == signed_char_type_node
                         || typ1 == unsigned_char_type_node);
       bool wchar_array = !!comptypes (typ1, wchar_type_node);
-      if (char_array || wchar_array)
+      bool char16_array = !!comptypes (typ1, char16_type_node);
+      bool char32_array = !!comptypes (typ1, char32_type_node);
+
+      if (char_array || wchar_array || char16_array || char32_array)
        {
          struct c_expr expr;
-         bool char_string;
+         tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
          expr.value = inside_init;
          expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
          maybe_warn_string_init (type, expr);
 
-         char_string
-           = (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)))
-              == char_type_node);
-
          if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
                         TYPE_MAIN_VARIANT (type)))
            return inside_init;
 
-         if (!wchar_array && !char_string)
+         if (char_array)
            {
-             error_init ("char-array initialized from wide string");
-             return error_mark_node;
+             if (typ2 != char_type_node)
+               {
+                 error_init ("char-array initialized from wide string");
+                 return error_mark_node;
+               }
            }
-         if (char_string && !char_array)
+         else
            {
-             error_init ("wchar_t-array initialized from non-wide string");
-             return error_mark_node;
+             if (typ2 == char_type_node)
+               {
+                 error_init ("wide character array initialized from non-wide "
+                             "string");
+                 return error_mark_node;
+               }
+             else if (!comptypes(typ1, typ2))
+               {
+                 error_init ("wide character array initialized from "
+                             "incompatible wide string");
+                 return error_mark_node;
+               }
            }
 
          TREE_TYPE (inside_init) = type;
          if (TYPE_DOMAIN (type) != 0
              && TYPE_SIZE (type) != 0
              && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-             /* Subtract 1 (or sizeof (wchar_t))
+             /* Subtract the size of a single (possibly wide) character
                 because it's ok to ignore the terminating null char
                 that is counted in the length of the constant.  */
              && 0 > compare_tree_int (TYPE_SIZE_UNIT (type),
                                       TREE_STRING_LENGTH (inside_init)
-                                      - ((TYPE_PRECISION (typ1)
-                                          != TYPE_PRECISION (char_type_node))
-                                         ? (TYPE_PRECISION (wchar_type_node)
-                                            / BITS_PER_UNIT)
-                                         : 1)))
+                                      - (TYPE_PRECISION (typ1)
+                                         / BITS_PER_UNIT)))
            pedwarn_init ("initializer-string for array of chars is too long");
 
          return inside_init;
@@ -6092,15 +6101,7 @@ set_nonincremental_init_from_string (tree str)
 
   gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
 
-  if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str)))
-      == TYPE_PRECISION (char_type_node))
-    wchar_bytes = 1;
-  else
-    {
-      gcc_assert (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str)))
-                 == TYPE_PRECISION (wchar_type_node));
-      wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT;
-    }
+  wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
   charwidth = TYPE_PRECISION (char_type_node);
   type = TREE_TYPE (constructor_type);
   p = TREE_STRING_POINTER (str);
index d67a10b0283f21b920cfd22730ef04b3139d2558..6daff1e9df5b7a166602e94ef1f900c3579bacac 100644 (file)
@@ -1,4 +1,10 @@
-2008-07-18  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+2008-07-18  Kris Van Hees  <kris.van.hees@oracle.com>
+
+       * rtti.c (emit_support_tinfos): Add char16_type_node and
+       char32_type_node.
+       * typeck2.c (digest_init): Support char16_t and char32_t.
+
+2008-07-18  Kavih R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * cvt.c (convert_to_void): Avoid C++ keywords.
        * decl.c (walk_namespaces_r, wrapup_globals_for_namespace):
@@ -59,9 +65,9 @@
 2008-07-11  Dodji Seketeli  <dseketel@redhat.com>
 
        PR c++/31754
-       * cp-tree.h (struct cp_decl_specifier_seq): add a location field. It
+       * cp-tree.h (struct cp_decl_specifier_seq): Add a location field. It
        carries the location of the primary type.
-       * parser.c (cp_parser_check_type_definition): update documentation.
+       * parser.c (cp_parser_check_type_definition): Update documentation.
        (cp_parser_check_for_definition_in_return_type,
        cp_parser_check_for_invalid_template_id,
        cp_parser_set_decl_spec_type,
        cp_parser_diagnose_invalid_type_name,
        cp_parser_new_expression, cp_parser_explicit_instantiation,
        cp_parser_type_specifier, cp_parser_simple_type_specifier,
-       cp_parser_omp_for_loop, cp_parser_pragma): use location in error messages.
-
+       cp_parser_omp_for_loop, cp_parser_pragma): Use location in error
+       messages.
 
 2008-07-11 Dodji Seketeli <dseketel@redhat.com>
 
        PR c++/31754
        * pt.c, semantic.c:
        * semantic.c (qualified_name_lookup_error, finish_id_expression):
-       add a location_t parameter so that
+       Add a location_t parameter so that
        error message can have a more accurate location.
-       * cp-tree.h: updated prototype
-       * pt.c (tsubst_qualified_id): use location in error messages.
+       * cp-tree.h: Updated prototype
+       * pt.c (tsubst_qualified_id): Use location in error messages.
        * parser.c (cp_parser_postfix_expression,
        cp_parser_objc_statement, cp_parser_trait_expr,
        cp_parser_token_is_class_key,
        cp_parser_function_specifier_opt, cp_parser_decltype,
        cp_parser_mem_initializer_list, cp_parser_mem_initializer,
        cp_parser_mem_initializer_id, cp_parser_template_parameter,
-       cp_parser_type_parameter, cp_parser_template_id, cp_parser_template_name,
-       cp_parser_template_argument): likewise.
+       cp_parser_type_parameter, cp_parser_template_id,
+       cp_parser_template_name, cp_parser_template_argument): Likewise.
 
 2008-07-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
index 8a36f0b77b7d55c548799fa4c8b5a87ff32ab913..d2e544b0f9e63dd21e7416bbffd51f699cf46656 100644 (file)
@@ -1408,7 +1408,7 @@ emit_support_tinfos (void)
   {
     &void_type_node,
     &boolean_type_node,
-    &wchar_type_node,
+    &wchar_type_node, &char16_type_node, &char32_type_node,
     &char_type_node, &signed_char_type_node, &unsigned_char_type_node,
     &short_integer_type_node, &short_unsigned_type_node,
     &integer_type_node, &unsigned_type_node,
index 4cf8021964f591ab995e6d5027c54e6da54e8174..a30ff547f188dc6a65aa0019388ac2d5ca7e0404 100644 (file)
@@ -727,17 +727,26 @@ digest_init_r (tree type, tree init, bool nested)
        {
          tree char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init)));
 
-         if (char_type != char_type_node
-             && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
+         if (TYPE_PRECISION (typ1) == BITS_PER_UNIT)
            {
-             error ("char-array initialized from wide string");
-             return error_mark_node;
+             if (char_type != char_type_node)
+               {
+                 error ("char-array initialized from wide string");
+                 return error_mark_node;
+               }
            }
-         if (char_type == char_type_node
-             && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
+         else
            {
-             error ("int-array initialized from non-wide string");
-             return error_mark_node;
+             if (char_type == char_type_node)
+               {
+                 error ("int-array initialized from non-wide string");
+                 return error_mark_node;
+               }
+             else if (char_type != typ1)
+               {
+                 error ("int-array initialized from incompatible wide string");
+                 return error_mark_node;
+               }
            }
 
          TREE_TYPE (init) = type;
index cdf587a21ee7c3a756ff66a01b3e97f3da8f921d..79793fd3999a2ad832a480a218f41afb8a70bcfa 100644 (file)
@@ -1,3 +1,15 @@
+2008-07-18  Kris Van Hees  <kris.van.hees@oracle.com>
+
+       Tests for char16_t and char32_t support.
+       * g++.dg/ext/utf-array.C: New
+       * g++.dg/ext/utf-array-short-wchar.C: New
+       * g++.dg/ext/utf-rtti.C: New
+       * g++.dg/ext/utf-type.c: New
+       * gcc.dg/utf-array.c: New
+       * gcc.dg/utf-array-short-wchar.c: New
+       * gcc.dg/utf-inc-init.c: New
+       * gcc.dg/utf-type.c: New
+
 2008-07-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR middle-end/36859
diff --git a/gcc/testsuite/g++.dg/ext/utf-array-short-wchar.C b/gcc/testsuite/g++.dg/ext/utf-array-short-wchar.C
new file mode 100644 (file)
index 0000000..7d768d3
--- /dev/null
@@ -0,0 +1,72 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x -fshort-wchar" } */
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char32_t s32_4[0] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_5[1] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_6[2] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_7[3] = U"ab";
+const char32_t s32_8[4] = U"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x -fshort-wchar" } */
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s32_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_7[3] = u"ab";
+const char16_t s32_8[4] = u"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
diff --git a/gcc/testsuite/g++.dg/ext/utf-array.C b/gcc/testsuite/g++.dg/ext/utf-array.C
new file mode 100644 (file)
index 0000000..ff6e12d
--- /dev/null
@@ -0,0 +1,72 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char32_t s32_4[0] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_5[1] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_6[2] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_7[3] = U"ab";
+const char32_t s32_8[4] = U"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=c++0x" } */
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s32_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_6[2] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_7[3] = u"ab";
+const char16_t s32_8[4] = u"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
diff --git a/gcc/testsuite/g++.dg/ext/utf-rtti.C b/gcc/testsuite/g++.dg/ext/utf-rtti.C
new file mode 100644 (file)
index 0000000..b5d201b
--- /dev/null
@@ -0,0 +1,12 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that typeinfo data is generated for char16_t/char32_t. */
+/* { dg-do link } */
+/* { dg-options "-std=c++0x" } */
+
+#include <typeinfo>
+
+int main(void)
+{
+    typeid(char16_t).name();
+    typeid(char32_t).name();
+}
diff --git a/gcc/testsuite/g++.dg/ext/utf-type.C b/gcc/testsuite/g++.dg/ext/utf-type.C
new file mode 100644 (file)
index 0000000..41a83ff
--- /dev/null
@@ -0,0 +1,15 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that __CHAR16_TYPE__ and __CHAR32_TYPE__ exist, match the types they
+   are the underlying data type for. */
+/* { dg-do run } */
+/* { dg-options "-std=c++0x -Wall -Werror" } */
+
+extern "C" void abort (void);
+
+int main ()
+{
+    if (sizeof (__CHAR16_TYPE__) != sizeof (char16_t))
+       abort();
+    if (sizeof (__CHAR32_TYPE__) != sizeof (char32_t))
+       abort();
+}
diff --git a/gcc/testsuite/gcc.dg/utf-array-short-wchar.c b/gcc/testsuite/gcc.dg/utf-array-short-wchar.c
new file mode 100644 (file)
index 0000000..3f34caa
--- /dev/null
@@ -0,0 +1,82 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -fshort-wchar" } */
+
+#include <wchar.h>
+
+typedef short unsigned int     char16_t;
+typedef unsigned int           char32_t;
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char32_t s32_4[0] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_5[1] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_6[2] = U"ab";
+const char32_t s32_7[3] = U"ab";
+const char32_t s32_8[4] = U"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -fshort-wchar" } */
+
+#include <wchar.h>
+
+typedef short unsigned int     char16_t;
+typedef unsigned int           char32_t;
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s32_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_6[2] = u"ab";
+const char16_t s32_7[3] = u"ab";
+const char16_t s32_8[4] = u"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
diff --git a/gcc/testsuite/gcc.dg/utf-array.c b/gcc/testsuite/gcc.dg/utf-array.c
new file mode 100644 (file)
index 0000000..0e36e0d
--- /dev/null
@@ -0,0 +1,82 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <wchar.h>
+
+typedef short unsigned int     char16_t;
+typedef unsigned int           char32_t;
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char32_t s32_4[0] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_5[1] = U"ab";       /* { dg-warning "chars is too long" } */
+const char32_t s32_6[2] = U"ab";
+const char32_t s32_7[3] = U"ab";
+const char32_t s32_8[4] = U"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Expected errors for char16_t/char32_t string literals. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <wchar.h>
+
+typedef short unsigned int     char16_t;
+typedef unsigned int           char32_t;
+
+const char     s_0[]   = "ab";
+const char     s_1[]   = u"ab";        /* { dg-error "from wide string" } */
+const char     s_2[]   = U"ab";        /* { dg-error "from wide string" } */
+const char     s_3[]   = L"ab";        /* { dg-error "from wide string" } */
+
+const char16_t s16_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char16_t s16_1[] = u"ab";
+const char16_t s16_2[] = U"ab";        /* { dg-error "from incompatible" } */
+const char16_t s16_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s16_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s16_6[2] = u"ab";
+const char16_t s16_7[3] = u"ab";
+const char16_t s16_8[4] = u"ab";
+
+const char32_t s32_0[] = "ab";         /* { dg-error "from non-wide" } */
+const char32_t s32_1[] = u"ab";        /* { dg-error "from incompatible" } */
+const char32_t s32_2[] = U"ab";
+const char32_t s32_3[] = L"ab";        /* { dg-error "from incompatible" } */
+
+const char16_t s32_4[0] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_5[1] = u"ab";       /* { dg-warning "chars is too long" } */
+const char16_t s32_6[2] = u"ab";
+const char16_t s32_7[3] = u"ab";
+const char16_t s32_8[4] = u"ab";
+
+const wchar_t  sw_0[]  = "ab";         /* { dg-error "from non-wide" } */
+const wchar_t  sw_1[]  = u"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_2[]  = U"ab";        /* { dg-error "from incompatible" } */
+const wchar_t  sw_3[]  = L"ab";
diff --git a/gcc/testsuite/gcc.dg/utf-inc-init.c b/gcc/testsuite/gcc.dg/utf-inc-init.c
new file mode 100644 (file)
index 0000000..17d59f3
--- /dev/null
@@ -0,0 +1,45 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Test incremental initializers for char16_t/char32_t arrays. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef short unsigned int char16_t;
+typedef unsigned int char32_t;
+
+extern int memcmp (const void *, const void *, size_t);
+extern void abort (void);
+extern void exit (int);
+
+struct A {
+  char16_t S[6];
+  int M;
+} a[] = { { { u"foo" }, 1 }, [0].S[2] = u'x', [0].S[4] = u'y' };
+struct A b[] = { { { u"foo" }, 1 }, [0] = { .S[0] = u'b' } };
+struct A c[] = { { { u"foo" }, 1 }, [0].S = { u"a" }, [0].M = 2 };
+
+struct B {
+  char32_t S[6];
+  int M;
+} d[] = { { { U"foo" }, 1 }, [0].S[2] = U'x', [0].S[4] = U'y' };
+struct B e[] = { { { U"foo" }, 1 }, [0] = { .S[0] = U'b' } };
+struct B f[] = { { { U"foo" }, 1 }, [0].S = { U"a" }, [0].M = 2 };
+
+int main (void)
+{
+  if (memcmp (a[0].S, u"fox\0y", 6 * sizeof(char16_t)) || a[0].M != 1)
+    abort ();
+  if (memcmp (b[0].S, u"b\0\0\0\0", 6) || b[0].M)
+    abort ();
+  if (memcmp (c[0].S, u"a\0\0\0\0", 6) || c[0].M != 2)
+    abort ();
+
+  if (memcmp (d[0].S, U"fox\0y", 6 * sizeof(char32_t)) || d[0].M != 1)
+    abort ();
+  if (memcmp (e[0].S, U"b\0\0\0\0", 6) || e[0].M)
+    abort ();
+  if (memcmp (f[0].S, U"a\0\0\0\0", 6) || f[0].M != 2)
+    abort ();
+
+  exit(0);
+}
diff --git a/gcc/testsuite/gcc.dg/utf-type.c b/gcc/testsuite/gcc.dg/utf-type.c
new file mode 100644 (file)
index 0000000..1aa6020
--- /dev/null
@@ -0,0 +1,18 @@
+/* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */
+/* Ensure that __CHAR16_TYPE__ and __CHAR32_TYPE__ exist, and are of the
+   correct width. */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99 -Wall -Werror" } */
+
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+
+extern void abort (void);
+
+int main ()
+{
+    if (sizeof (char16_t) != sizeof (u'a'))
+       abort();
+    if (sizeof (char32_t) != sizeof (U'a'))
+       abort();
+}
index 03f42d3d167e3bd944ebfc3d72e7b594646d3069..4389f606c5c0133d52f3a2d7b3d7b3b60ae7ff5d 100644 (file)
@@ -1,3 +1,11 @@
+2008-07-18  Kris Van Hees  <kris.van.hees@oracle.com>
+           Holger Hopp  <holger.hopp@sap.com>
+
+       * config/abi/pre/gnu.ver: Support char16_t and char32_t.
+       * testsuite/util/testsuite_abi.cc (check_version): Add
+       CXXABI_1.3.3 to known_versions.
+
+
 2008-07-16  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * include/debug/vector (insert(iterator, _Tp&&), push_back(_Tp&&)):
index a9c94fc694b90d7fd61149fe680fce14eee96d9a..ced293a0dd1322f0557f4dc1128a419c4d315f26 100644 (file)
@@ -1012,3 +1012,15 @@ CXXABI_1.3.2 {
     _ZTIN10__cxxabiv119__foreign_exceptionE;
 
 } CXXABI_1.3.1;
+
+CXXABI_1.3.3 {
+
+    # typeinfo for char16_t and char32_t
+    _ZTIu8char16_t;
+    _ZTIPu8char16_t;
+    _ZTIPKu8char16_t;
+    _ZTIu8char32_t;
+    _ZTIPu8char32_t;
+    _ZTIPKu8char32_t;
+
+} CXXABI_1.3.2;
index 6466fbabcd80b037aa64e3127bba6302f7fab151..c15b8b24447932970743a24edca9176b303e382f 100644 (file)
@@ -199,6 +199,7 @@ check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_1.3");
       known_versions.push_back("CXXABI_1.3.1");
       known_versions.push_back("CXXABI_1.3.2");
+      known_versions.push_back("CXXABI_1.3.3");
       known_versions.push_back("CXXABI_LDBL_1.3");
     }
   compat_list::iterator begin = known_versions.begin();