This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Do not deal with circularity in add_gnat_descriptive_type_attribute
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 Oct 2011 00:10:24 +0200
- Subject: Do not deal with circularity in add_gnat_descriptive_type_attribute
GNAT uses the special DW_AT_GNAT_descriptive_type attribute to describe the
structure of complex types (discriminated records with variant parts). This
attribute points to another record type, which can partially replicate the
structure of the original type. In particular, it can indirectly points back
to the original type.
This circularity is perfectly handled by the main code path, but going through
add_gnat_descriptive_type_attribute breaks this handling and can lead to the
creation of duplicate attributes for DIEs. The attached patch prevents this
from happening with a trick based on TYPE_DECL_SUPPRESS_DEBUG.
Bootstrapped/regtested on i586-suse-linux. Since this affects only GNAT, I'm
applying it on the mainline directly. Better ideas welcome though.
2011-10-25 Eric Botcazou <ebotcazou@adacore.com>
* dwarf2out.c (add_gnat_descriptive_type_attribute): Temporarily
suppress debug info for the parent type.
--
Eric Botcazou
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 180423)
+++ dwarf2out.c (working copy)
@@ -15415,7 +15415,11 @@ add_gnat_descriptive_type_attribute (dw_
dtype_die = lookup_type_die (dtype);
if (!dtype_die)
{
+ /* The descriptive type indirectly references TYPE if this is also the
+ case for TYPE itself. Do not deal with the circularity here. */
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)) = 1;
gen_type_die (dtype, context_die);
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)) = 0;
dtype_die = lookup_type_die (dtype);
gcc_assert (dtype_die);
}