[Ada] clean up handling of DECL_ORIGINAL_TYPE in gigi

Eric Botcazou ebotcazou@adacore.com
Tue Jun 21 21:34:00 GMT 2016


More specifically the ??? comment:

	  /* ??? Copy and original type are not supposed to be variant but we
	     really need a variant for the placeholder machinery to work.  */
	  if (TYPE_IS_FAT_POINTER_P (t))
	    tt = build_variant_type_copy (t);
	  else
	    {
	      /* TYPE_NEXT_PTR_TO is a chain of main variants.  */
	      tt = build_distinct_type_copy (TYPE_MAIN_VARIANT (t));
	      if (TREE_CODE (t) == POINTER_TYPE)
		TYPE_NEXT_PTR_TO (TYPE_MAIN_VARIANT (t)) = tt;
	      tt = build_qualified_type (tt, TYPE_QUALS (t));
	    }

The C family of compilers always uses a variant in this case so the attached 
patch does the same for the Ada compiler.  The verify_type_variant hunk is 
necessary because it would flag differences for TYPE_SIZE and TYPE_SIZE_UNIT 
between variants that are spurious: the trees are initially the same but they 
are reset to different PLACEHOLDER_EXPRs by free_lang_data_in_one_sizepos:

/* Reset the expression *EXPR_P, a size or position.

   ??? We could reset all non-constant sizes or positions.  But it's cheap
   enough to not do so and refrain from adding workarounds to dwarf2out.c.

   We need to reset self-referential sizes or positions because they cannot
   be gimplified and thus can contain a CALL_EXPR after the gimplification
   is finished, which will run afoul of LTO streaming.  And they need to be
   reset to something essentially dummy but not constant, so as to preserve
   the properties of the object they are attached to.  */

static inline void
free_lang_data_in_one_sizepos (tree *expr_p)
{
  tree expr = *expr_p;
  if (CONTAINS_PLACEHOLDER_P (expr))
    *expr_p = build0 (PLACEHOLDER_EXPR, TREE_TYPE (expr));
}

Tested on x86_64-suse-linux, applied on the mainline, as obvious for the 
verify_type_variant hunk.


2016-06-21  Eric Botcazou  <ebotcazou@adacore.com>

	* tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if
	they are both PLACEHOLDER_EXPRs.
ada/
	* gcc-interface/decl.c (set_nonaliased_component_on_array_type): New
	function.
	(set_reverse_storage_order_on_array_type): Likewise.
	(gnat_to_gnu_entity) <E_Array_Type>: Call them to set the flags.
	<E_Array_Subtype>: Likewise.
	<E_String_Literal_Subtype>: Likewise.
	(substitute_in_type) <ARRAY_TYPE>: Likewise.
	* gcc-interface/utils.c (gnat_pushdecl): Always create a variant for
	the DECL_ORIGINAL_TYPE of a type.

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 6763 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160621/8071179f/attachment.bin>


More information about the Gcc-patches mailing list