This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] honor DECL_BY_REFERENCE on CALL_EXPR exp in aggregate_value_p


Hello,

With the GCC 3.4 series, a front-end requesting a function to return
by invisible reference used to merely have to set TREE_ADDRESSABLE on
the proper types.

Current mainline now expects everything to be exposed explicitely, as
illustrated by cp_genericize for C++, for instance. Amongst other things,
the function result decl is marked DECL_BY_REFERENCE and the associated
type is made an explicit reference type.

The Ada front-end has not gone through this transition yet and relies on the
gimplifier for temporary creations in a number of circumstances.

One kind of observable effect is ICEs from attempts at creating temporaries of
TREE_ADDRESSABLE type, e.g. while compiling check_result_by_ref.adb in the
testcase below.

We are working at resolving this issue.  Part of our current scheme consists
in unsetting the TREE_ADDRESSABLE flag on the function type, which prevents
part of the middle-end magic to work - in particular, the following bits from
expand_call:

     /* Set up a place to return a structure.  */
     ...
     if (aggregate_value_p (exp, fndecl))

The attached patch is a simple helper for the aforementioned expand_call
issue, preriquisite for a larger change to come, hence part of a regression
fix.

Bootstrapped and successfully regression tested with languages=all,ada
on i686-pc-linux-gnu.

2006-06-24  Olivier Hainque  <hainque@adacore.com>

        * function.c (aggregate_value_p): Honor DECL_BY_REFERENCE on
        a CALL_EXPR target function declaration.

Thanks in advance.

Olivier

--

Testcase:

   -- result_by_ref.ads
   package Result_By_Ref is
      type Point is record
	 X, Y, Z : Integer;
      end record;

      function Ref_Loc return Point;
      pragma Export_Function
	(Ref_Loc,  External => "Loc", Result_Mechanism => Reference);

      Ref_Point : Point := (0, 0, 0);
   end;

   -- result_by_ref.adb
   package body Result_By_Ref is
      function Ref_Loc return Point is
      begin
	 return Ref_Point;
      end;
   end;

   -- check_result_by_ref.adb
   with Result_By_Ref; use Result_By_Ref;
   procedure Check_Result_By_Ref is
      L : Point := Ref_Loc;
   begin
      if L /= Ref_Point then
	 raise Program_Error;
      end if;
   end;

--







Attachment: result-byref.dif
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]