This patch fixes a compiler abort on a program with a type that has defined dynamic predicate and a call to a procedure with a parameter of that type, when the program is compiled with -gnatc.
The following must compile quietly: gcc -c -gnatc p-q.adb --- with Unchecked_Conversion; package P is function Is_Valid_Name (Item : String) return Boolean; subtype Name_T is String with Dynamic_Predicate => Is_Valid_Name (Name_T); generic type T is private; package G is function Conv is new Unchecked_Conversion (Source => T, Target => Integer); end G; end P; --- package P.Q is type Rec is record B : Integer; end record; package My_G is new G (Rec); procedure Proc (Name : Name_T); end P.Q; --- package body P.Q is procedure Proc (Name : Name_T) is begin null; end; end P.Q; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-10-20 Ed Schonberg <schonb...@adacore.com> * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Generate freeze node for subprogram in Compile_Only mode.
Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 229023) +++ sem_ch6.adb (working copy) @@ -3215,18 +3215,17 @@ -- the freeze actions that include the bodies. In particular, extra -- formals for accessibility or for return-in-place may need to be -- generated. Freeze nodes, if any, are inserted before the current - -- body. These freeze actions are also needed in ASIS mode to enable - -- the proper back-annotations. + -- body. These freeze actions are also needed in ASIS mode and in + -- Compile_Only mode to enable the proper back-end type annotations. + -- They are necessary in any case to insure order of elaboration + -- in gigi. if not Is_Frozen (Spec_Id) - and then (Expander_Active or ASIS_Mode) + and then (Expander_Active + or else ASIS_Mode + or else (Operating_Mode = Check_Semantics + and then Serious_Errors_Detected = 0)) then - -- Force the generation of its freezing node to ensure proper - -- management of access types in the backend. - - -- This is definitely needed for some cases, but it is not clear - -- why, to be investigated further??? - Set_Has_Delayed_Freeze (Spec_Id); Freeze_Before (N, Spec_Id); end if;