Commit 7b019c19 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (char_type_p): New function.

	* cp-tree.h (char_type_p): New function.
	* decl.c (init_decl_processing): Don't initialize
	signed_wchar_type_node or unsigned_wchar_type_node.
	(complete_array_type): Handle brace-enclosed string-constants.
	* rtti.c (emit_support_tinfos): Remove #if 0'd code.
	* tree.c (char_type_p): New function.
	* typeck2.c (digest_init): Use char_type_p.

From-SVN: r34936
parent 93d87cb1
2000-07-09 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (char_type_p): New function.
* decl.c (init_decl_processing): Don't initialize
signed_wchar_type_node or unsigned_wchar_type_node.
(complete_array_type): Handle brace-enclosed string-constants.
* rtti.c (emit_support_tinfos): Remove #if 0'd code.
* tree.c (char_type_p): New function.
* typeck2.c (digest_init): Use char_type_p.
2000-07-06 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (tsubst): Don't layout type, if it's error_mark.
......
......@@ -4547,7 +4547,8 @@ extern void remap_save_expr PARAMS ((tree *, splay_tree, tre
extern tree build_shared_int_cst PARAMS ((int));
extern special_function_kind special_function_p PARAMS ((tree));
extern int count_trees PARAMS ((tree));
extern int char_type_p PARAMS ((tree));
/* in typeck.c */
extern int string_conv_p PARAMS ((tree, tree, int));
extern tree condition_conversion PARAMS ((tree));
......
......@@ -6549,12 +6549,10 @@ init_decl_processing ()
: WCHAR_TYPE);
wchar_type_node = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (wchar_type_node));
wchar_type_size = TYPE_PRECISION (wchar_type_node);
signed_wchar_type_node = make_signed_type (wchar_type_size);
unsigned_wchar_type_node = make_unsigned_type (wchar_type_size);
wchar_type_node
= TREE_UNSIGNED (wchar_type_node)
? unsigned_wchar_type_node
: signed_wchar_type_node;
if (TREE_UNSIGNED (wchar_type_node))
wchar_type_node = make_signed_type (wchar_type_size);
else
wchar_type_node = make_unsigned_type (wchar_type_size);
record_builtin_type (RID_WCHAR, "__wchar_t", wchar_type_node);
/* Artificial declaration of wchar_t -- can be bashed */
......@@ -8637,8 +8635,18 @@ complete_array_type (type, initial_value, do_default)
if (initial_value)
{
/* Note MAXINDEX is really the maximum index,
one less than the size. */
/* An array of character type can be initialized from a
brace-enclosed string constant. */
if (char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)))
&& TREE_CODE (initial_value) == CONSTRUCTOR
&& CONSTRUCTOR_ELTS (initial_value)
&& (TREE_CODE (TREE_VALUE (CONSTRUCTOR_ELTS (initial_value)))
== STRING_CST)
&& TREE_CHAIN (CONSTRUCTOR_ELTS (initial_value)) == NULL_TREE)
initial_value = TREE_VALUE (CONSTRUCTOR_ELTS (initial_value));
/* Note MAXINDEX is really the maximum index, one less than the
size. */
if (TREE_CODE (initial_value) == STRING_CST)
{
int eltsize
......
......@@ -445,6 +445,14 @@ void __cxa_vec_ctor (void *__array_address,
void (*__constructor) (void *),
void (*__destructor) (void *));
extern "C++"
void __cxa_vec_cctor (void *dest_array,
void *src_array,
__SIZE_TYPE__ element_count,
__SIZE_TYPE__ element_size,
void (*constructor) (void *, void *),
void (*destructor) (void *));
/* destruct array */
extern "C++"
void __cxa_vec_dtor (void *__array_address,
......
......@@ -1970,23 +1970,12 @@ emit_support_tinfos ()
&void_type_node,
&boolean_type_node,
&wchar_type_node,
#if 0
&signed_wchar_type_node, &unsigned_wchar_type_node,
#endif
&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,
&long_integer_type_node, &long_unsigned_type_node,
&long_long_integer_type_node, &long_long_unsigned_type_node,
&float_type_node, &double_type_node, &long_double_type_node,
/* GCC extension types */
#if 0
&complex_integer_type_node,
&complex_float_type_node, &complex_double_type_node,
&complex_long_double_type_node,
#endif
0
};
int ix;
......
......@@ -2488,3 +2488,15 @@ special_function_p (decl)
return sfk_none;
}
/* Returns non-zero if TYPE is a character type, including wchar_t. */
int
char_type_p (type)
tree type;
{
return (same_type_p (type, char_type_node)
|| same_type_p (type, unsigned_char_type_node)
|| same_type_p (type, signed_char_type_node)
|| same_type_p (type, wchar_type_node));
}
......@@ -573,11 +573,7 @@ digest_init (type, init, tail)
}
typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
if ((typ1 == char_type_node
|| typ1 == signed_char_type_node
|| typ1 == unsigned_char_type_node
|| typ1 == unsigned_wchar_type_node
|| typ1 == signed_wchar_type_node)
if (char_type_p (typ1)
&& ((init && TREE_CODE (init) == STRING_CST)
|| (element && TREE_CODE (element) == STRING_CST)))
{
......
......@@ -94,6 +94,35 @@ __cxa_vec_ctor (void *array_address,
}
}
/* construct an array by copying */
extern "C++" void
__cxa_vec_cctor (void *dest_array,
void *src_array,
size_t element_count,
size_t element_size,
void (*constructor) (void *, void *),
void (*destructor) (void *))
{
size_t ix = 0;
char *dest_ptr = static_cast <char *> (dest_array);
char *src_ptr = static_cast <char *> (src_array);
try
{
if (constructor)
for (; ix != element_count;
ix++, src_ptr += element_size, dest_ptr += element_size)
constructor (dest_ptr, src_ptr);
}
catch (...)
{
__uncatch_exception ();
__cxa_vec_dtor (dest_array, ix, element_size, destructor);
throw;
}
}
/* destruct array */
extern "C++" void
__cxa_vec_dtor (void *array_address,
......
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