with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
+with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem_Aux; use Sem_Aux;
with Sem_Util; use Sem_Util;
function Enable_Put_Image (Typ : Entity_Id) return Boolean is
begin
+ -- Disable in pre-2020 versions for now???
+
+ if Ada_Version < Ada_2020 then
+ return False;
+ end if;
+
-- There's a bit of a chicken&egg problem. The compiler is likely to
-- have trouble if we refer to the Put_Image of Sink itself, because
-- Sink is part of the parameter profile:
-- Put_Image doesn't work for private types whose full type is real.
if Is_Remote_Types (Scope (Typ))
- or else Is_Tagged_Type (Typ)
+ or else (Is_Tagged_Type (Typ) and then In_Predefined_Unit (Typ))
or else Is_Real_Type (Typ)
then
return False;
end if;
end;
+ -- Disable for CPP types, because the components are unavailable on the
+ -- Ada side.
+
+ if Is_Tagged_Type (Typ)
+ and then Convention (Typ) = Convention_CPP
+ and then Is_CPP_Class (Root_Type (Typ))
+ then
+ return False;
+ end if;
+
return Is_Scalar_Type (Typ) or else not In_Predefined_Unit (Typ);
end Enable_Put_Image;
return Make_Defining_Identifier (Loc, Sname);
end Make_Put_Image_Name;
- ----------------------
+ ------------------
+ -- Preload_Sink --
+ ------------------
+
+ procedure Preload_Sink is
+ begin
+ if RTE_Available (RE_Sink) then
+ declare
+ Ignore : constant Entity_Id := RTE (RE_Sink);
+ begin
+ null;
+ end;
+ end if;
+ end Preload_Sink;
+
+ -------------------------
-- Put_Image_Base_Type --
- ----------------------
+ -------------------------
function Put_Image_Base_Type (E : Entity_Id) return Entity_Id is
begin
function Build_Unknown_Put_Image_Call (N : Node_Id) return Node_Id;
-- Build a call to Put_Image_Unknown
+ procedure Preload_Sink;
+ -- Call RTE (RE_Sink), to load the packages involved in Put_Image. We
+ -- need to do this explicitly, fairly early during compilation, because
+ -- otherwise it happens during freezing, which triggers visibility bugs
+ -- in generic instantiations.
+
end Exp_Put_Image;
with Debug; use Debug;
with Einfo; use Einfo;
with Errout; use Errout;
+with Exp_Put_Image;
with Exp_Util; use Exp_Util;
with Elists; use Elists;
with Fname; use Fname;
-- Start of processing for Analyze_Compilation_Unit
begin
+ -- We can't call Preload_Sink for at least some predefined units,
+ -- because it would introduce cyclic dependences. The package where Sink
+ -- is declared, for example, and things it depends on. See Exp_Put_Image
+ -- for documentation. We don't call Preload_Sink in pre-2020 Ada
+ -- versions, because the default Put_Image is disabled in those
+ -- versions, at least for now.
+
+ if Ada_Version >= Ada_2020 and then not In_Predefined_Unit (N) then
+ Exp_Put_Image.Preload_Sink;
+ end if;
+
Process_Compilation_Unit_Pragmas (N);
-- If the unit is a subunit whose parent has not been analyzed (which