From 5101b304668b06b6ef938a0acc84ba03debc816a Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 12 Apr 2001 01:44:21 +0000 Subject: dwarf2out.c (modified_type_die): Don't create new types here. * dwarf2out.c (modified_type_die): Don't create new types here. * tree.h (get_qualified_type): New function. (build_qualified_type): Adjust comment. * tree.c (get_qualified_type): New function. (build_qualified_type): Use it. From-SVN: r41276 --- gcc/tree.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'gcc/tree.c') diff --git a/gcc/tree.c b/gcc/tree.c index c4334ce..1d880d7 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2993,31 +2993,47 @@ set_type_quals (type, type_quals) TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0; } -/* Given a type node TYPE and a TYPE_QUALIFIER_SET, return a type for - the same kind of data as TYPE describes. Variants point to the - "main variant" (which has no qualifiers set) via TYPE_MAIN_VARIANT, - and it points to a chain of other variants so that duplicate - variants are never made. Only main variants should ever appear as - types of expressions. */ +/* Return a version of the TYPE, qualified as indicated by the + TYPE_QUALS, if one exists. If no qualified version exists yet, + return NULL_TREE. */ tree -build_qualified_type (type, type_quals) +get_qualified_type (type, type_quals) tree type; int type_quals; { - register tree t; + tree t; /* Search the chain of variants to see if there is already one there just like the one we need to have. If so, use that existing one. We must preserve the TYPE_NAME, since there is code that depends on this. */ - for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) if (TYPE_QUALS (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type)) return t; - /* We need a new one. */ - t = build_type_copy (type); - set_type_quals (t, type_quals); + return NULL_TREE; +} + +/* Like get_qualified_type, but creates the type if it does not + exist. This function never returns NULL_TREE. */ + +tree +build_qualified_type (type, type_quals) + tree type; + int type_quals; +{ + tree t; + + /* See if we already have the appropriate qualified variant. */ + t = get_qualified_type (type, type_quals); + + /* If not, build it. */ + if (!t) + { + t = build_type_copy (type); + set_type_quals (t, type_quals); + } + return t; } -- cgit v1.1