In ASIS mode the compiler creates and analyzes instance bodies in generic units and applies semantic checks on record components. Checks on staticness of components must not be applied to them, as they would not be in the standard compilation mode.
The following must compile quietly: gcc -c -gnatct p.adb -- with Q; package body P is type R is record A : T; end record with Size => 8; for R use record A at 0 range 0 .. 7; end record; procedure Do_Something is procedure G is new Q.Gen_G (Element_Type => R, Element_Size => 1); begin null; end Do_Something; end P; --- generic type T is (<>); package P is procedure Do_Something; end P; --- with System.Storage_Elements; package Q is generic type Element_Type is private; Element_Size : System.Storage_Elements.Storage_Count; procedure Gen_G; end Q; --- with Ada.Unchecked_Conversion; package body Q is procedure Gen_G is use type System.Storage_Elements.Storage_Count; subtype Elements_As_Storage_Array is System.Storage_Elements.Storage_Array (1 .. Element_Size); function Convert is new Ada.Unchecked_Conversion (Source => Element_Type, Target => Elements_As_Storage_Array); begin pragma Compile_Time_Error (Element_Size * 8 /= Element_Type'Size, "Wrong value of Element_Size"); end Gen_G; end Q; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-10-31 Ed Schonberg <schonb...@adacore.com> * freeze.adb (Freeze_Record_Type): Do not check component size if its type is generic.
Index: freeze.adb =================================================================== --- freeze.adb (revision 216955) +++ freeze.adb (working copy) @@ -3356,6 +3356,14 @@ elsif CodePeer_Mode then null; + -- Omit check if component has a generic type. This can + -- happen in an instantiation within a generic in ASIS + -- mode, where we force freeze actions without full + -- expansion. + + elsif Is_Generic_Type (Etype (Comp)) then + null; + -- Do the check elsif not