]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.c (check_qualified_type): New fn.
authorJason Merrill <jason@gcc.gnu.org>
Tue, 24 Feb 2004 18:23:25 +0000 (13:23 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 24 Feb 2004 18:23:25 +0000 (13:23 -0500)
        * 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

gcc/ChangeLog
gcc/cp/tree.c
gcc/tree.c
gcc/tree.h

index 99cbcb3f71c7c16c8aa5219a042ddd0712a6d5c3..102d04c7fb9cdac4b51cd88b182ef8db01192b5a 100644 (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,
 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>
index 8cba3d633a2fd16fe655d58c31e9787cba8d1fd4..f8b33da5a4102b77256d1f9074414ea4f07b6c22 100644 (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.  */
index d2b79bcca3cfc211eb4174fc62c73e670fbc4e21..3913b55f33e3dd66bb9408b40c9267645578bdcc 100644 (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;
index 25ba23a211e56c661fc54dfb516870814d10fb39..7846b545c21517ac78490726253a99e98706c46e 100644 (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.  */