This is the mail archive of the 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]

[Ada] Fix internal error on inlining of renamed subprogram instantiation

This fixes an assertion failure in gigi triggered by an order-of-elaboration
issue for the type of a parameter of a subprogram which is both the renaming
of another subprogram and marked Inline.  In this case the compiler was using
expansion (aka front-end inlining) but this doesn't always play nice with the
freezing model used for generics so the patch makes it use back-end inlining.

The following package must compile quietly with -O -gnatn:

with F;
with G;

package P is

  function Uid_Image (Uid : Integer) return String;

  package Inner is
    type Arr is array (Positive range <>) of Integer;
    function Image is new F (Integer, Positive, Arr, Uid_Image);
  end Inner;

  package Value_Set is new G (Integer);

  function Uid_Image (Uid : Integer) return String renames Value_Set.Uid_Image;
  pragma Inline (Uid_Image);

end P;
  type Item_T is limited private;
  type Index_T is (<>);
  type Array_T is array (Index_T range <>) of Item_T;
  with function Image (Item : Item_T) return String;
function F (A : Array_T) return String;
with Ada.Strings.Unbounded;

function F (A : Array_T) return String is
  Result : Ada.Strings.Unbounded.Unbounded_String;
  for I in A'Range loop
    Ada.Strings.Unbounded.Append (Result, Image (A (I)));
  end loop;
  return Ada.Strings.Unbounded.To_String (Result);

  type T is range <>;

package G is

  function Uid_Image (Uid : T) return String;

end G;
package body G is

  function Uid_Image (Uid : T) return String is
    return T'Image (Uid);

end G;

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-02-20  Eric Botcazou  <>

	* inline.adb (Expand_Inlined_Call): Skip again calls to subprogram
	* exp_ch6.adb (Expand_Call): Use back-end inlining
	instead of expansion for simple subprogram renamings.

Attachment: difs
Description: Text document

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