Commit 896c3aa3 by Jason Merrill

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
parent 58565a33
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> 2003-02-24 Sanjiv Kumar Gupta <sanjivg@noida.hcltech.com>
* target-def.h (TARGET_SCHED_INIT_GLOBAL, * target-def.h (TARGET_SCHED_INIT_GLOBAL,
...@@ -1864,7 +1872,7 @@ ...@@ -1864,7 +1872,7 @@
2004-02-10 Danny Smith <dannysmith@users.sourceforge.net> 2004-02-10 Danny Smith <dannysmith@users.sourceforge.net>
PR c/14088 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. hexfloat strings.
2004-02-10 Kazu Hirata <kazu@cs.umass.edu> 2004-02-10 Kazu Hirata <kazu@cs.umass.edu>
......
...@@ -990,9 +990,8 @@ build_exception_variant (tree type, tree raises) ...@@ -990,9 +990,8 @@ build_exception_variant (tree type, tree raises)
int type_quals = TYPE_QUALS (type); int type_quals = TYPE_QUALS (type);
for (; v; v = TYPE_NEXT_VARIANT (v)) for (; v; v = TYPE_NEXT_VARIANT (v))
if (TYPE_QUALS (v) == type_quals if (check_qualified_type (v, type, type_quals)
&& comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1) && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1))
&& (*targetm.comp_type_attributes) (type, v))
return v; return v;
/* Need to build a new variant. */ /* Need to build a new variant. */
......
...@@ -2967,6 +2967,19 @@ set_type_quals (tree type, int type_quals) ...@@ -2967,6 +2967,19 @@ set_type_quals (tree type, int type_quals)
TYPE_RESTRICT (type) = (type_quals & TYPE_QUAL_RESTRICT) != 0; 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 /* Return a version of the TYPE, qualified as indicated by the
TYPE_QUALS, if one exists. If no qualified version exists yet, TYPE_QUALS, if one exists. If no qualified version exists yet,
return NULL_TREE. */ return NULL_TREE. */
...@@ -2976,13 +2989,14 @@ get_qualified_type (tree type, int type_quals) ...@@ -2976,13 +2989,14 @@ get_qualified_type (tree type, int type_quals)
{ {
tree t; tree t;
if (TYPE_QUALS (type) == type_quals)
return type;
/* Search the chain of variants to see if there is already one there just /* 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 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. */ preserve the TYPE_NAME, since there is code that depends on this. */
for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
if (TYPE_QUALS (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type) if (check_qualified_type (t, type, type_quals))
&& TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
&& attribute_list_equal (TYPE_ATTRIBUTES (t), TYPE_ATTRIBUTES (type)))
return t; return t;
return NULL_TREE; return NULL_TREE;
......
...@@ -2304,6 +2304,11 @@ extern tree merge_attributes (tree, tree); ...@@ -2304,6 +2304,11 @@ extern tree merge_attributes (tree, tree);
extern tree merge_dllimport_decl_attributes (tree, tree); extern tree merge_dllimport_decl_attributes (tree, tree);
#endif #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 /* Return a version of the TYPE, qualified as indicated by the
TYPE_QUALS, if one exists. If no qualified version exists yet, TYPE_QUALS, if one exists. If no qualified version exists yet,
return NULL_TREE. */ return NULL_TREE. */
......
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