Commit c466b2cd by Kris Van Hees

c-common.c (c_stddef_cpp_builtins): Define __CHAR16_TYPE__ and __CHAR32_TYPE__.

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
parent ab07512c
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> 2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36859 PR middle-end/36859
......
...@@ -4895,6 +4895,8 @@ c_stddef_cpp_builtins(void) ...@@ -4895,6 +4895,8 @@ c_stddef_cpp_builtins(void)
builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0); builtin_define_with_value ("__WINT_TYPE__", WINT_TYPE, 0);
builtin_define_with_value ("__INTMAX_TYPE__", INTMAX_TYPE, 0); builtin_define_with_value ("__INTMAX_TYPE__", INTMAX_TYPE, 0);
builtin_define_with_value ("__UINTMAX_TYPE__", UINTMAX_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 static void
......
...@@ -4704,47 +4704,56 @@ digest_init (tree type, tree init, bool strict_string, int require_constant) ...@@ -4704,47 +4704,56 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
|| typ1 == signed_char_type_node || typ1 == signed_char_type_node
|| typ1 == unsigned_char_type_node); || typ1 == unsigned_char_type_node);
bool wchar_array = !!comptypes (typ1, wchar_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; struct c_expr expr;
bool char_string; tree typ2 = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (inside_init)));
expr.value = inside_init; expr.value = inside_init;
expr.original_code = (strict_string ? STRING_CST : ERROR_MARK); expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
maybe_warn_string_init (type, expr); 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)), if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)),
TYPE_MAIN_VARIANT (type))) TYPE_MAIN_VARIANT (type)))
return inside_init; return inside_init;
if (!wchar_array && !char_string) if (char_array)
{ {
error_init ("char-array initialized from wide string"); if (typ2 != char_type_node)
return error_mark_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"); if (typ2 == char_type_node)
return error_mark_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; TREE_TYPE (inside_init) = type;
if (TYPE_DOMAIN (type) != 0 if (TYPE_DOMAIN (type) != 0
&& TYPE_SIZE (type) != 0 && TYPE_SIZE (type) != 0
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST && 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 because it's ok to ignore the terminating null char
that is counted in the length of the constant. */ that is counted in the length of the constant. */
&& 0 > compare_tree_int (TYPE_SIZE_UNIT (type), && 0 > compare_tree_int (TYPE_SIZE_UNIT (type),
TREE_STRING_LENGTH (inside_init) TREE_STRING_LENGTH (inside_init)
- ((TYPE_PRECISION (typ1) - (TYPE_PRECISION (typ1)
!= TYPE_PRECISION (char_type_node)) / BITS_PER_UNIT)))
? (TYPE_PRECISION (wchar_type_node)
/ BITS_PER_UNIT)
: 1)))
pedwarn_init ("initializer-string for array of chars is too long"); pedwarn_init ("initializer-string for array of chars is too long");
return inside_init; return inside_init;
...@@ -6092,15 +6101,7 @@ set_nonincremental_init_from_string (tree str) ...@@ -6092,15 +6101,7 @@ set_nonincremental_init_from_string (tree str)
gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE); gcc_assert (TREE_CODE (constructor_type) == ARRAY_TYPE);
if (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) wchar_bytes = TYPE_PRECISION (TREE_TYPE (TREE_TYPE (str))) / BITS_PER_UNIT;
== 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;
}
charwidth = TYPE_PRECISION (char_type_node); charwidth = TYPE_PRECISION (char_type_node);
type = TREE_TYPE (constructor_type); type = TREE_TYPE (constructor_type);
p = TREE_STRING_POINTER (str); p = TREE_STRING_POINTER (str);
......
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. * cvt.c (convert_to_void): Avoid C++ keywords.
* decl.c (walk_namespaces_r, wrapup_globals_for_namespace): * decl.c (walk_namespaces_r, wrapup_globals_for_namespace):
...@@ -59,9 +65,9 @@ ...@@ -59,9 +65,9 @@
2008-07-11 Dodji Seketeli <dseketel@redhat.com> 2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754 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. 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_definition_in_return_type,
cp_parser_check_for_invalid_template_id, cp_parser_check_for_invalid_template_id,
cp_parser_set_decl_spec_type, cp_parser_set_decl_spec_type,
...@@ -69,18 +75,18 @@ ...@@ -69,18 +75,18 @@
cp_parser_diagnose_invalid_type_name, cp_parser_diagnose_invalid_type_name,
cp_parser_new_expression, cp_parser_explicit_instantiation, cp_parser_new_expression, cp_parser_explicit_instantiation,
cp_parser_type_specifier, cp_parser_simple_type_specifier, 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> 2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754 PR c++/31754
* pt.c, semantic.c: * pt.c, semantic.c:
* semantic.c (qualified_name_lookup_error, finish_id_expression): * 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. error message can have a more accurate location.
* cp-tree.h: updated prototype * cp-tree.h: Updated prototype
* pt.c (tsubst_qualified_id): use location in error messages. * pt.c (tsubst_qualified_id): Use location in error messages.
* parser.c (cp_parser_postfix_expression, * parser.c (cp_parser_postfix_expression,
cp_parser_objc_statement, cp_parser_trait_expr, cp_parser_objc_statement, cp_parser_trait_expr,
cp_parser_token_is_class_key, cp_parser_token_is_class_key,
...@@ -103,8 +109,8 @@ ...@@ -103,8 +109,8 @@
cp_parser_function_specifier_opt, cp_parser_decltype, cp_parser_function_specifier_opt, cp_parser_decltype,
cp_parser_mem_initializer_list, cp_parser_mem_initializer, cp_parser_mem_initializer_list, cp_parser_mem_initializer,
cp_parser_mem_initializer_id, cp_parser_template_parameter, cp_parser_mem_initializer_id, cp_parser_template_parameter,
cp_parser_type_parameter, cp_parser_template_id, cp_parser_template_name, cp_parser_type_parameter, cp_parser_template_id,
cp_parser_template_argument): likewise. cp_parser_template_name, cp_parser_template_argument): Likewise.
2008-07-09 Paolo Carlini <paolo.carlini@oracle.com> 2008-07-09 Paolo Carlini <paolo.carlini@oracle.com>
......
...@@ -1408,7 +1408,7 @@ emit_support_tinfos (void) ...@@ -1408,7 +1408,7 @@ emit_support_tinfos (void)
{ {
&void_type_node, &void_type_node,
&boolean_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, &char_type_node, &signed_char_type_node, &unsigned_char_type_node,
&short_integer_type_node, &short_unsigned_type_node, &short_integer_type_node, &short_unsigned_type_node,
&integer_type_node, &unsigned_type_node, &integer_type_node, &unsigned_type_node,
......
...@@ -727,17 +727,26 @@ digest_init_r (tree type, tree init, bool nested) ...@@ -727,17 +727,26 @@ digest_init_r (tree type, tree init, bool nested)
{ {
tree char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init))); tree char_type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (init)));
if (char_type != char_type_node if (TYPE_PRECISION (typ1) == BITS_PER_UNIT)
&& TYPE_PRECISION (typ1) == BITS_PER_UNIT)
{ {
error ("char-array initialized from wide string"); if (char_type != char_type_node)
return error_mark_node; {
error ("char-array initialized from wide string");
return error_mark_node;
}
} }
if (char_type == char_type_node else
&& TYPE_PRECISION (typ1) != BITS_PER_UNIT)
{ {
error ("int-array initialized from non-wide string"); if (char_type == char_type_node)
return error_mark_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; TREE_TYPE (init) = type;
......
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> 2008-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/36859 PR middle-end/36859
......
/* 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";
/* 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";
/* 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();
}
/* 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();
}
/* 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";
/* 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";
/* 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);
}
/* 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();
}
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> 2008-07-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/debug/vector (insert(iterator, _Tp&&), push_back(_Tp&&)): * include/debug/vector (insert(iterator, _Tp&&), push_back(_Tp&&)):
......
...@@ -1012,3 +1012,15 @@ CXXABI_1.3.2 { ...@@ -1012,3 +1012,15 @@ CXXABI_1.3.2 {
_ZTIN10__cxxabiv119__foreign_exceptionE; _ZTIN10__cxxabiv119__foreign_exceptionE;
} CXXABI_1.3.1; } 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;
...@@ -199,6 +199,7 @@ check_version(symbol& test, bool added) ...@@ -199,6 +199,7 @@ check_version(symbol& test, bool added)
known_versions.push_back("CXXABI_1.3"); known_versions.push_back("CXXABI_1.3");
known_versions.push_back("CXXABI_1.3.1"); known_versions.push_back("CXXABI_1.3.1");
known_versions.push_back("CXXABI_1.3.2"); known_versions.push_back("CXXABI_1.3.2");
known_versions.push_back("CXXABI_1.3.3");
known_versions.push_back("CXXABI_LDBL_1.3"); known_versions.push_back("CXXABI_LDBL_1.3");
} }
compat_list::iterator begin = known_versions.begin(); compat_list::iterator begin = known_versions.begin();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment