This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] Fix PR debug/40666
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 7 Jul 2009 13:15:17 +0200
- Subject: [Patch] Fix PR debug/40666
Hi,
this is a regression present in 4.4.x: the Ada tools fail to build with STABS.
It pertains to OUT parameters, which are handled quite specially since they
are translated into variables in Gigi, with the following tweak:
/* If we are defining an Out parameter and we're not optimizing,
create a fake PARM_DECL for debugging purposes and make it
point to the VAR_DECL. Suppress debug info for the latter
but make sure it will still live on the stack so it can be
accessed from within the debugger through the PARM_DECL. */
if (kind == E_Out_Parameter && definition && !optimize)
{
tree param = create_param_decl (gnu_entity_id, gnu_type, false);
gnat_pushdecl (param, gnat_entity);
SET_DECL_VALUE_EXPR (param, gnu_decl);
DECL_HAS_VALUE_EXPR_P (param) = 1;
if (debug_info_p)
debug_info_p = false;
else
DECL_IGNORED_P (param) = 1;
TREE_ADDRESSABLE (gnu_decl) = 1;
}
The DECL_HAS_VALUE_EXPR trick works out of the box for DWARF but it requires
the following small adjustment for STABS. Cross-tested for PA/HP-UX. OK for
mainline and 4.4 branch?
2009-07-07 Eric Botcazou <ebotcazou@adacore.com>
PR debug/40666
* dbxout.c (dbxout_symbol) <PARM_DECL>: Deal with parameters pointing
to variables for debugging purposes.
--
Eric Botcazou
Index: dbxout.c
===================================================================
--- dbxout.c (revision 149204)
+++ dbxout.c (working copy)
@@ -2778,9 +2778,15 @@ dbxout_symbol (tree decl, int local ATTR
}
case PARM_DECL:
- /* Parm decls go in their own separate chains
- and are output by dbxout_reg_parms and dbxout_parms. */
- gcc_unreachable ();
+ if (DECL_HAS_VALUE_EXPR_P (decl))
+ decl = DECL_VALUE_EXPR (decl);
+
+ /* PARM_DECLs go in their own separate chain and are output by
+ dbxout_reg_parms and dbxout_parms, except for those that are
+ disguised VAR_DECLs like Out parameters in Ada. */
+ gcc_assert (TREE_CODE (decl) == VAR_DECL);
+
+ /* ... fall through ... */
case RESULT_DECL:
case VAR_DECL: