tree.c (check_qualified_type): New fn.

* tree.c (check_qualified_type): New fn.
        (get_qualified_type): Use it.  If type already has the desired
        quals, just return it.
        * tree.h: Declare it.
        * cp/tree.c (build_exception_variant): Use it.

From-SVN: r78376
This commit is contained in:
Jason Merrill 2004-02-24 13:23:25 -05:00
parent 58565a33ed
commit 896c3aa346
4 changed files with 33 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2004-02-24 Jason Merrill <jason@redhat.com>
* tree.c (check_qualified_type): New fn.
(get_qualified_type): Use it. If type already has the desired
quals, just return it.
* tree.h: Declare it.
* cp/tree.c (build_exception_variant): Use it.
2003-02-24 Sanjiv Kumar Gupta <sanjivg@noida.hcltech.com>
* target-def.h (TARGET_SCHED_INIT_GLOBAL,
@ -1864,7 +1872,7 @@
2004-02-10 Danny Smith <dannysmith@users.sourceforge.net>
PR c/14088
real.c (real_from_string): Look for 'X' as well as 'x' in
* real.c (real_from_string): Look for 'X' as well as 'x' in
hexfloat strings.
2004-02-10 Kazu Hirata <kazu@cs.umass.edu>

View File

@ -990,9 +990,8 @@ build_exception_variant (tree type, tree raises)
int type_quals = TYPE_QUALS (type);
for (; v; v = TYPE_NEXT_VARIANT (v))
if (TYPE_QUALS (v) == type_quals
&& comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1)
&& (*targetm.comp_type_attributes) (type, v))
if (check_qualified_type (v, type, type_quals)
&& comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1))
return v;
/* Need to build a new variant. */

View File

@ -2967,6 +2967,19 @@ set_type_quals (tree type, int type_quals)
TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
}
/* Returns true iff cand is equivalent to base with type_quals. */
bool
check_qualified_type (tree cand, tree base, int type_quals)
{
return (TYPE_QUALS (cand) == type_quals
&& TYPE_NAME (cand) == TYPE_NAME (base)
/* Apparently this is needed for Objective-C. */
&& TYPE_CONTEXT (cand) == TYPE_CONTEXT (base)
&& attribute_list_equal (TYPE_ATTRIBUTES (cand),
TYPE_ATTRIBUTES (base)));
}
/* 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. */
@ -2976,13 +2989,14 @@ get_qualified_type (tree type, int type_quals)
{
tree t;
if (TYPE_QUALS (type) == type_quals)
return type;
/* 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)
&& TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
&& attribute_list_equal (TYPE_ATTRIBUTES (t), TYPE_ATTRIBUTES (type)))
if (check_qualified_type (t, type, type_quals))
return t;
return NULL_TREE;

View File

@ -2304,6 +2304,11 @@ extern tree merge_attributes (tree, tree);
extern tree merge_dllimport_decl_attributes (tree, tree);
#endif
/* Check whether CAND is suitable to be returned from get_qualified_type
(BASE, TYPE_QUALS). */
extern bool check_qualified_type (tree, tree, int);
/* 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. */