]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
dwarf2out.c (is_subrange_type): Do not emit a subrange_type DIE for base types.
authorJoel Brobecker <brobecker@gnat.com>
Mon, 22 Mar 2004 20:57:00 +0000 (20:57 +0000)
committerJoel Brobecker <brobecke@gcc.gnu.org>
Mon, 22 Mar 2004 20:57:00 +0000 (20:57 +0000)
        * dwarf2out.c (is_subrange_type): Do not emit a subrange_type DIE
        for base types.

From-SVN: r79838

gcc/ChangeLog
gcc/dwarf2out.c

index 4237524377759ff9b53199e56951fc83dcd16bb0..daebc141599787bfff320cb4629b28aca628847f 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-22  Joel Brobecker  <brobecker@gnat.com>
+
+       * dwarf2out.c (is_subrange_type): Do not emit a subrange_type DIE
+       for base types.
+
 2004-03-22  Joel Brobecker  <brobecker@gnat.com>
 
        * dwarf2out.c (is_subrange_type): Minor code rework. No behavior
index ad2bf63aaec7ee7fbde51b8875fef13a269399af..4a1745353c4b50b00c2726f56ed52feadf82c7cc 100644 (file)
@@ -8012,6 +8012,38 @@ is_subrange_type (tree type)
       && TREE_CODE (subtype) != ENUMERAL_TYPE)
     return false;
 
+  if (TREE_CODE (type) == TREE_CODE (subtype)
+      && int_size_in_bytes (type) == int_size_in_bytes (subtype)
+      && TYPE_MIN_VALUE (type) != NULL
+      && TYPE_MIN_VALUE (subtype) != NULL
+      && tree_int_cst_equal (TYPE_MIN_VALUE (type), TYPE_MIN_VALUE (subtype))
+      && TYPE_MAX_VALUE (type) != NULL
+      && TYPE_MAX_VALUE (subtype) != NULL
+      && tree_int_cst_equal (TYPE_MAX_VALUE (type), TYPE_MAX_VALUE (subtype)))
+    {
+      /* The type and its subtype have the same representation.  If in
+         addition the two types also have the same name, then the given
+         type is not a subrange type, but rather a plain base type.  */
+      /* FIXME: brobecker/2004-03-22:
+         Sizetype INTEGER_CSTs nodes are canonicalized.  It should
+         therefore be sufficient to check the TYPE_SIZE node pointers
+         rather than checking the actual size.  Unfortunately, we have
+         found some cases, such as in the Ada "integer" type, where
+         this is not the case.  Until this problem is solved, we need to
+         keep checking the actual size.  */
+      tree type_name = TYPE_NAME (type);
+      tree subtype_name = TYPE_NAME (subtype);
+
+      if (type_name != NULL && TREE_CODE (type_name) == TYPE_DECL)
+        type_name = DECL_NAME (type_name);
+
+      if (subtype_name != NULL && TREE_CODE (subtype_name) == TYPE_DECL)
+        subtype_name = DECL_NAME (subtype_name);
+
+      if (type_name == subtype_name)
+        return false;
+    }
+
   return true;
 }