Commit db3626d1 by Mark Mitchell Committed by Mark Mitchell

tree.c (cp_build_qualified_type_real): Rework ARRAY_TYPE allocation to match…

tree.c (cp_build_qualified_type_real): Rework ARRAY_TYPE allocation to match practice throughout the rest of the compiler.

	* tree.c (cp_build_qualified_type_real): Rework ARRAY_TYPE
	allocation to match practice throughout the rest of the
	compiler.

From-SVN: r27264
parent 3c567fae
1999-05-31 Mark Mitchell <mark@codesourcery.com>
* tree.c (cp_build_qualified_type_real): Rework ARRAY_TYPE
allocation to match practice throughout the rest of the
compiler.
1999-05-30 Mark Mitchell <mark@codesourcery.com> 1999-05-30 Mark Mitchell <mark@codesourcery.com>
* lex.c (make_lang_type): Create TYPE_BINFO for * lex.c (make_lang_type): Create TYPE_BINFO for
......
...@@ -403,21 +403,18 @@ build_cplus_array_type_1 (elt_type, index_type) ...@@ -403,21 +403,18 @@ build_cplus_array_type_1 (elt_type, index_type)
tree elt_type; tree elt_type;
tree index_type; tree index_type;
{ {
register struct obstack *ambient_obstack = current_obstack;
register struct obstack *ambient_saveable_obstack = saveable_obstack;
tree t; tree t;
if (elt_type == error_mark_node || index_type == error_mark_node) if (elt_type == error_mark_node || index_type == error_mark_node)
return error_mark_node; return error_mark_node;
push_obstacks_nochange ();
/* We need a new one. If both ELT_TYPE and INDEX_TYPE are permanent, /* We need a new one. If both ELT_TYPE and INDEX_TYPE are permanent,
make this permanent too. */ make this permanent too. */
if (TREE_PERMANENT (elt_type) if (TREE_PERMANENT (elt_type)
&& (index_type == 0 || TREE_PERMANENT (index_type))) && (index_type == 0 || TREE_PERMANENT (index_type)))
{ end_temporary_allocation ();
current_obstack = &permanent_obstack;
saveable_obstack = &permanent_obstack;
}
if (processing_template_decl if (processing_template_decl
|| uses_template_parms (elt_type) || uses_template_parms (elt_type)
...@@ -432,10 +429,11 @@ build_cplus_array_type_1 (elt_type, index_type) ...@@ -432,10 +429,11 @@ build_cplus_array_type_1 (elt_type, index_type)
/* Push these needs up so that initialization takes place /* Push these needs up so that initialization takes place
more easily. */ more easily. */
TYPE_NEEDS_CONSTRUCTING (t) = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type)); TYPE_NEEDS_CONSTRUCTING (t)
TYPE_NEEDS_DESTRUCTOR (t) = TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type)); = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
current_obstack = ambient_obstack; TYPE_NEEDS_DESTRUCTOR (t)
saveable_obstack = ambient_saveable_obstack; = TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
pop_obstacks ();
return t; return t;
} }
...@@ -500,30 +498,43 @@ cp_build_qualified_type_real (type, type_quals, complain) ...@@ -500,30 +498,43 @@ cp_build_qualified_type_real (type, type_quals, complain)
} }
else if (TREE_CODE (type) == ARRAY_TYPE) else if (TREE_CODE (type) == ARRAY_TYPE)
{ {
tree real_main_variant = TYPE_MAIN_VARIANT (type); /* In C++, the qualification really applies to the array element
tree element_type = cp_build_qualified_type_real (TREE_TYPE (type), type. Obtain the appropriately qualified element type. */
type_quals, tree t;
complain); tree element_type
push_obstacks (TYPE_OBSTACK (real_main_variant), = cp_build_qualified_type_real (TREE_TYPE (type),
TYPE_OBSTACK (real_main_variant)); type_quals,
type = build_cplus_array_type_1 (element_type, complain);
TYPE_DOMAIN (type));
if (type == error_mark_node) if (element_type == error_mark_node)
return error_mark_node; return error_mark_node;
/* TYPE must be on same obstack as REAL_MAIN_VARIANT. If not, /* See if we already have an identically qualified type. */
make a copy. (TYPE might have come from the hash table and for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
REAL_MAIN_VARIANT might be in some function's obstack.) */ if (CP_TYPE_QUALS (t) == type_quals)
break;
if (TYPE_OBSTACK (type) != TYPE_OBSTACK (real_main_variant)) /* If we didn't already have it, create it now. */
if (!t)
{ {
type = copy_node (type); /* Make a new array type, just like the old one, but with the
TYPE_POINTER_TO (type) = TYPE_REFERENCE_TO (type) = 0; appropriately qualified element type. */
t = build_type_copy (type);
TREE_TYPE (t) = element_type;
} }
TYPE_MAIN_VARIANT (type) = real_main_variant; /* Even if we already had this variant, we update
pop_obstacks (); TYPE_NEEDS_CONSTRUCTING and TYPE_NEEDS_DESTRUCTOR in case
return type; they changed since the variant was originally created.
This seems hokey; if there is some way to use a previous
variant *without* coming through here,
TYPE_NEEDS_CONSTRUCTING will never be updated. */
TYPE_NEEDS_CONSTRUCTING (t)
= TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (element_type));
TYPE_NEEDS_DESTRUCTOR (t)
= TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (element_type));
return t;
} }
return build_qualified_type (type, type_quals); return build_qualified_type (type, type_quals);
} }
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
void h(T&);
template <class T>
void g ()
{
h ("abcdefghi");
}
template void g<int>();
template <class T>
void h(T&)
{
T t = {};
}
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