[PATCH] Fix up debuginfo for VLAs in nested functions

Ian Lance Taylor iant@google.com
Fri Apr 24 22:01:00 GMT 2009


Jakub Jelinek <jakub@redhat.com> writes:

> One of the changes needed is to honor DECL_BY_REFERENCE even for VAR_DECLs
> (those which tree-nested.c creates as replacement for
> PARM_DECLs/RESULT_DECLs).  Unfortunately, ATM DECL_BY_REFERENCE shares the
> same bit as TREE_PRIVATE.  I believe the C++ FE (the only setter of
> TREE_PRIVATE) only sets this on FUNCTION_DECLs/FIELD_DECLs and
> static data members (i.e. TREE_STATIC VAR_DECLs), so this patch extends
> DECL_BY_REFERENCE uses from PARM_DECL/RESULT_DECL also to !TREE_STATIC
> VAR_DECLs.  Without this parameters passed by invisible reference
> referenced from nested routines will show up as pointers in the debug info,
> which is undesirable.

This overloading will eventually cause a bug if we don't check for it
when ENABLE_TREE_CHECKING is defined.  Can you, in a separate patch,
modify TREE_PRIVATE and DECL_BY_REFERENCE to verify that they are being
invoked appropriately?  Also modify TREE_PROTECTED to check the same set
of conditions as TREE_PRIVATE.  Then fix any fallout.


> 2009-04-08  Jakub Jelinek  <jakub@redhat.com>
>
> 	* tree.h (DECL_BY_REFERENCE): Note that it is also valid for
> 	!TREE_STATIC VAR_DECLs.
> 	* dwarf2out.c (loc_by_reference, gen_decl_die): Handle
> 	DECL_BY_REFERENCE on !TREE_STATIC VAR_DECLs.
> 	(gen_variable_die): Likewise.  Don't look at TREE_PRIVATE if
> 	DECL_BY_REFERENCE is valid.
> 	* dbxout.c (DECL_ACCESSIBILITY_CHAR): Don't look at TREE_PRIVATE
> 	for PARM_DECLs, RESULT_DECLs or !TREE_STATIC VAR_DECLs.
> 	* tree-nested.c (get_nonlocal_debug_decl, get_local_debug_decl):
> 	Copy DECL_BY_REFERENCE.
> 	(struct nesting_copy_body_data): New type.
> 	(nesting_copy_decl): New function.
> 	(finalize_nesting_tree_1): Remap types of debug_var_chain variables,
> 	if they have variable length.

This is OK.

Thanks.

Ian



More information about the Gcc-patches mailing list