I apologize.
I reworked the code in a single program:
---------------------------------------------------------------------------
with Ada.Finalization;
procedure My_Test is
generic
package Handled_Record is
type Base_Object is new Ada.Finalization.Controlled with null record;
not overriding procedure Finalize_Handle(Object: Base_Object) is null;
generic
type Base is new Base_Object with private;
package With_Finalization is
type Derived is new Base with null record;
end;
end Handled_Record;
package Term is
package Term_Handled_Record is new Handled_Record;
type Term_Type_Without_Finalize is
new Term_Handled_Record.Base_Object with null record;
overriding procedure Finalize_Handle (Object: Term_Type_Without_Finalize);
type Term_Kind is (Literal);
type Term_Literal_Value is private;
not overriding function Get_Literal (Term: Term_Type_Without_Finalize)
return Term_Literal_Value;
package Finalizer is new
Term_Handled_Record.With_Finalization(Term_Type_Without_Finalize);
type Term_Type is new Finalizer.Derived with null record;
private
type Term_Literal_Value is null record;
end Term;
package body Term is
function Get_Literal (Term: Term_Type_Without_Finalize)
return Term_Literal_Value is
begin
return (null record);
end;
procedure Finalize_Handle (Object: Term_Type_Without_Finalize) is
begin
null;
end;
end Term;
begin
null;
end My_Test;
--------------------------------------------------------------------------
Compiling with gnat 4.9.3 crashes the compiler (Storage_Error stack overflow or erroneous memory access at my_test.adb:3:1)
Compiling with gnat-2017 from
libre.adacore.com the compilation goes well (obviously it does nothing).
The original code is split in three modules (handled_record.ads, term.ads, term.adb).
With both compilers it give the error:
system.ads:1:01: declaration must appear after completion of type "Term_Literal_Value"
gnatmake: "term.adb" compilation error
Removing the lines:
type Derived is new Base with null record;
and
type Term_Type is new Finalizer.Derived with null record;
from my_test.adb and from the original modules the compilation goes well.
Also with the modification I suggested in my first post the compilation goes well in both versions.
So I conclude:
The error happens at the freezing point, but with gnat-2017 only in the modular version.
The code could be legal because it works in the monolithic version, but after reading Randy's message I am no more sure of anything.
> Too sick to take on extra work...
Sorry to hear this, I hope you will be well soon.
A.