This introduces a new attribute Max_Integer_Size that can only be
applied to Standard and yields the size of the largest supported integer
type for the target.  It is primarily intended to implement
System.{Min,Max}_Int.

This also implements a couple of internal helper functions in the
compiler to return an appropriate integer type for a given size and
signedness.

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

gcc/ada/

        * doc/gnat_rm/implementation_defined_attributes.rst: Document the
        new Max_Integer_Size attribute.
        * gnat_rm.texi: Regenerate.
        * exp_attr.adb (Get_Integer_Type): Call Small_Integer_Type_For.
        (Expand_N_Attribute_Reference) <Attribute_Pred>: Replace selection
        code with call to Integer_Type_For.
        <Attribute_Succ>: Likewise.
        <Attribute_Val>: Likewise.
        <Attribute_Valid>: Likewise.
        <Attribute_Max_Integer_Size>: Raise Program_Error.
        * exp_ch3.adb (Expand_Freeze_Enumeration_Type): Replace selection
        code with call to Integer_Type_For.
        (Simple_Init_Initialize_Scalars_Type): Use Long_Long_Unsigned and
        System_Max_Integer_Size to size the largest integer type.
        * exp_pakd.adb (Compute_Linear_Subscript): Minor tweak.
        (Create_Packed_Array_Impl_Type): Use Small_Integer_Type_For.
        * exp_util.ads (Integer_Type_For): New function.
        (Small_Integer_Type_For): Likewise.
        * exp_util.adb (Adjust_Condition): Use Integer_Type_For.
        (Component_May_Be_Bit_Aligned): Use System_Max_Integer_Size.
        (Integer_Type_For): New function.
        (Small_Integer_Type_For): Likewise.
        (Matching_Standard_Type): Use Small_Integer_Type_For.
        (Needs_Constant_Address): Replace 64 with System_Max_Integer_Size.
        * freeze.adb (Set_Small_Size): Likewise.
        (Size_Known): Likewise.
        (Check_Suspicious_Modulus): Likewise.
        (Check_Large_Modular_Array): Likewise.
        (Freeze_Entity): Likewise.
        * layout.adb (Layout_Type): Likewise.
        * sem_aggr.adb: Add with and use clauses for Ttypes.
        (Resolve_Aggregate): Replace 64 with System_Max_Integer_Size.
        * sem_attr.ads (Attribute_Impl_Def): Add Attribute_Max_Integer_Size.
        * sem_attr.adb (Analyze_Attribute) <Attribute_Max_Integer_Size>: New
        (Eval_Attribute): Likewise.
        * sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Change max
        scalar size to System_Max_Integer_Size.
        (Check_Array_Type): Replace 64 with System_Max_Integer_Size and
        remove superfluous test.
        (OK_Component): Likewise.
        * sem_ch5.adb: Add with and use clauses for Ttypes.
        (Analyze_Assignment): Replace 64 with System_Max_Integer_Size.
        * snames.ads-tmpl (Name_Max_Integer_Size): New attribute name.
        (Attribute_Id): Add Attribute_Max_Integer_Size.
        * ttypes.ads (System_Max_Integer_Size): New constant.

Attachment: patch.diff.gz
Description: application/gzip

Reply via email to