aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
AgeCommit message (Collapse)AuthorFilesLines
2020-11-30[Ada] Expand integer-only implementation of ordinary fixed-point typesEric Botcazou1-0/+25
gcc/ada/ * doc/gnat_rm/implementation_defined_attributes.rst (Pool_Address): Fix pasto. (Small_Denominator): New entry. (Small_Numerator): Likewise. * doc/gnat_rm/implementation_defined_characteristics.rst (3.5.9): Relax conditions on 128-bit smalls and integer-only implementation. * gnat_rm.texi: Regenerate. * exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Fore>: Relax conditions on integer implementation for ordinary fixed-point types and pass a third parameter to the routine. <Attribute_Small_Denominator>: Raise Program_Error. <Attribute_Small_Numerator>: Likewise. * exp_fixd.adb (Expand_Convert_Fixed_To_Fixed): Use a scaled divide if the numerator and denominator of the small ratio are sufficiently small integers. (Expand_Convert_Fixed_To_Integer): Use a scaled divide if numerator and denominator of the small value are sufficiently small integers. (Expand_Convert_Integer_To_Fixed): Likewise. * exp_imgv.adb (Expand_Image_Attribute): Relax the conditions on the integer implementation for ordinary fixed-point types. (Expand_Value_Attribute): Likewise. * freeze.adb (Freeze_Fixed_Point_Type): Relax conditions on 128-bit smalls. * sem_attr.adb (Analyze_Attribute) <Attribute_Small_Denominator>: Check no arguments, fixed-point and set type to Universal_Integer. <Attribute_Small_Numerator>: Likewise. (Eval_Attribute) <Attribute_Small_Denominator>: Fold statically. <Attribute_Small_Numerator>: Likewise. * snames.ads-tmpl (Name_Small_Denominator): New attribute name. (Name_Small_Numerator): Likewise. (Attribute_Id): Add Attribute_Small_{Denominator,Numerator}. * libgnat/a-tifiio.adb (Exact): Delete. (Need_64): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/a-tifiio__128.adb (Exact): Delete. (Need_64): Likewise. (Need_128): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (OK_Get_128): Likewise. (OK_Put_128): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/a-wtfiio.adb (Exact): Delete. (Need_64): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/a-wtfiio__128.adb (Exact): Delete. (Need_64): Likewise. (Need_128): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (OK_Get_128): Likewise. (OK_Put_128): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/a-ztfiio.adb (Exact): Delete. (Need_64): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/a-ztfiio__128.adb (Exact): Delete. (Need_64): Likewise. (Need_128): Likewise. (OK_Get_32): New boolean constant. (OK_Put_32): Likewise. (OK_Get_64): Likewise. (OK_Put_64): Likewise. (OK_Get_128): Likewise. (OK_Put_128): Likewise. (E): Adjust. (Get procedures): Likewise. (Put procedures): Likewise. * libgnat/s-fore_f.ads (Fore_Fixed): Adjust signature. * libgnat/s-fore_f.adb (Fore_Fixed): Reimplement. * libgnat/s-fofi32.ads (Fore_Fixed32): Adjust signature. * libgnat/s-fofi64.ads (Fore_Fixed64): Likewise. * libgnat/s-fofi128.ads (Fore_Fixed128): Likewise. * libgnat/s-imagef.ads: Adjust description. * libgnat/s-imagef.adb (Maxdigs): Move around. (Set_Image_Integer): Remove assertion. * libgnat/s-valuef.ads: Adjust description. * libgnat/s-valuef.adb (Integer_To_Fixed): Minor tweak.
2020-11-27[Ada] Restore access type instead of mode out parameterPiotr Trojanek1-4/+4
gcc/ada/ * sem_eval.ads (Compile_Time_Compare): Restore parameter Diff to be of an access type. * sem_eval.adb (Compile_Time_Compare): Adapt body and callers. * sem_attr.adb (Eval_Attribute): Adapt callers.
2020-11-27[Ada] Change parameter from access type to mode outPiotr Trojanek1-4/+4
gcc/ada/ * sem_eval.ads (Compile_Time_Compare): Change parameter Diff from access to mode out. * sem_eval.adb (Compile_Time_Compare): Adapt body and callers. * sem_attr.adb (Eval_Attribute): Adapt callers.
2020-11-26[Ada] Issue advice for error regarding Old/Loop_Entry on unevaluated expr.Yannick Moy1-4/+12
gcc/ada/ * sem_attr.adb (Analyze_Attribute): Issue a continuation message to give proper recommendation here.
2020-11-25[Ada] Document attribute Has_Tagged_Values in GNAT RMPiotr Trojanek1-6/+5
gcc/ada/ * doc/gnat_rm/implementation_defined_attributes.rst (Has_Tagged_Values): Document based on the existing description of Has_Access_Type and the comment for Has_Tagged_Component, which is where frontend evaluates this attribute. * gnat_rm.texi: Regenerate. * sem_attr.adb (Analyze_Attribute): Merge processing of Has_Access_Type and Has_Tagged_Component attributes. * sem_util.adb (Has_Access_Type): Fix casing in comment. * sem_util.ads (Has_Tagged_Component): Remove wrong (or outdated) comment about the use of this routine to implement the equality operator.
2020-11-25[Ada] Remove repeated calls to Attribute_NamePiotr Trojanek1-7/+7
gcc/ada/ * exp_util.adb (Attribute_Constrained_Static_Value): Fix body box. * sem_attr.adb (Eval_Attribute): Replace repeated calls to Attribute_Name with a captured value of the Attribute_Id; also, remove extra parens around Is_Generic_Type.
2020-11-25[Ada] Reuse Is_Named_Number where possiblePiotr Trojanek1-1/+1
gcc/ada/ * sem_attr.adb, sem_prag.adb: Use Is_Named_Number.
2020-11-24[Ada] Accept local objects in the prefix of attribute Loop_EntryPiotr Trojanek1-1/+5
gcc/ada/ * sem_attr.adb (Declared_Within): Return True for objects declared within the attribute Loop_Entry prefix itself.
2020-10-26[Ada] Avoid crash on use of Ada 2020 featureBob Duff1-1/+1
gcc/ada/ * sem_attr.adb (Check_Image_Type): Remove "|", so the compiler will not crash. * errout.ads: Improve comment. This has nothing to do with -gnatQ.
2020-10-23[Ada] Further Ada 2020 work on accessibility checkingJustin Squirek1-5/+15
gcc/ada/ * checks.adb (Apply_Accessibility_Check): Skip checks against the extra accessibility of a function result when in Ada 2005 mode or earlier. * exp_ch3.adb (Build_Initialization_Call): Modify accessibility level calls to use Accessibility_Level. (Expand_N_Object_Declaration): Modify accessibility level calls to use Accessibility_Level. * exp_ch4.adb (Expand_Allocator_Expression): Add static check for anonymous access discriminants. Remove unneeded propagation of accessibility actual. (Expand_N_In): Modify accessibility level calls to use Accessibility_Level. (Expand_N_Type_Conversion): Modify accessibility level calls to use Accessibility_Level. * exp_ch5.adb (Expand_N_Assignment_Statement): Modify accessibility level calls to use Accessibility_Level. * exp_ch6.adb (Expand_Call_Helper): Rewrite accessibility calculation for the extra accessibility of result actual in function calls, and modify accessibility level calls to use Accessibility_Level. (Check_Against_Result_Level): Removed. * exp_ch9.adb (Expand_N_Requeue_Statement): Add dynamic accessibility check for requeues * sem_attr.adb (Resolve_Attribute): Modify accessibility level calls to use Accessibility_Level. * sem_ch13.adb (Associate_Storage_Pool): Modify accessibility level calls to use Accessibility_Level. * sem_ch4.adb (Analyze_Call): Add static check for explicitly aliased formals in function calls within return statements. * sem_ch6.adb (Check_Return_Construct_Accessibility): Rewrite routine to account for non-aggregate return objects. (Generate_Minimum_Accessibility): Created. (Analyze_Call): Modify accessibility level calls to use Accessibility_Level. (Analyze_Subprogram_Body_Helper): Add generation of minimum accessibility for the extra accessibility of the function result. * sem_ch9.adb (Analyze_Requeue): Modify accessibility level calls to use Accessibility_Level. * sem_res.adb: (Check_Aliased_Parameters): Modify accessibility level calls to use Accessibility_Level. (Valid_Conversion): Modify accessibility level calls to use Accessibility_Level. * sem_util.adb, sem_util.ads (Accessibility_Level_Helper): Renamed to Accessibility_Level, add detection for functions in prefix notation, and add cases where to return zero when specified. Modified to take new, more descriptive, parameters. (Accessibility_Level): Created. (Function_Call_Level): Removed. (Function_Call_Or_Allocator_Level): Created to centralize the calculation accessibility levels for function calls and allocators. (Static_Accessibility_Level): Removed. (Dynamic_Accessibility_Level): Removed. (Get_Dynamic_Accessibility): Renamed from Get_Accessibility. (In_Return_Value): Created to determine if a given expression contributes to the current function's return value. (Is_Master): Created. (Is_Explicitly_Aliased): Created
2020-10-23[Ada] Implement new legality rules introduced in C.6(12) by AI12-0363Eric Botcazou1-1/+22
gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst (VFA): Remove uage restrictions in conjunction with Atomic and Aliased. * gnat_rm.texi: Regenerate. * aspects.ads (Aspect_Id): Add Aspect_Full_Access_Only. (Is_Representation_Aspect): Likewise. (Aspect_Names): Likewise. (Aspect_Delay): Likewise. * einfo.ads (Is_Atomic_Or_VFA): Rename into... (Is_Full_Access): ...this. (Is_Volatile_Full_Access): Document new usage for Full_Access_Only. * einfo.adb (Is_Atomic_Or_VFA): Rename into... (Is_Full_Access): ...this. * freeze.ads (Is_Atomic_VFA_Aggregate): Rename into... (Is_Full_Access_Aggregate): ...this. * freeze.adb (Is_Atomic_VFA_Aggregate): Rename into... (Is_Full_Access_Aggregate): ...this. Adjust to above renaming. (Freeze_Array_Type): Likewise. (Freeze_Entity): Likewise. * exp_aggr.adb (Aggr_Assignment_OK_For_Backend): Likewise. (Expand_Record_Aggregate): Likewise. * exp_ch4.adb (Expand_N_Op_Eq): Likewise. * exp_ch5.adb (Expand_Assign_Array): Likewise. * exp_ch8.adb (Evaluation_Required): Likewise. * layout.adb (Layout_Type): Likewise. (Set_Composite_Alignment): Likewise. * sem_aux.ads (Has_Rep_Item): Delete. * sem_aux.adb (Has_Rep_Item): Likewise. * sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Implement new legality rules in C.6(12). * sem_ch12.adb (Instantiate_Object): Likewise. * sem_res.adb (Resolve_Actuals): Likewise. * sem_ch13.adb (Inherit_Delayed_Rep_Aspects): Deal with aspect Full_Access_Only. (Check_False_Aspect_For_Derived_Type): Likewise. (Make_Pragma_From_Boolean_Aspect): Test for the presence of Expr. Deal with aspect Full_Access_Only. (Analyze_Aspects_At_Freeze_Point): Likewise. (Analyze_One_Aspect): Do not set Delay_Required to true even for Always_Delay boolean aspects if they have no expression. Force Delay_Required to true for aspect Full_Access_Only in all cases. Reject aspect Full_Access_Only if not in Ada 2020 mode. (Check_Aspect_At_End_Of_Declarations): Deal with empty expression. (Check_Aspect_At_Freeze_Point): Likewise. (Rep_Item_Entity): Delete. (Inherit_Aspects_At_Freeze_Point): Align handling for Bit_Order with that for Scalar_Storage_Order. * sem_prag.adb (Check_Atomic_VFA): Delete. (Check_VFA_Conflicts): Likewise. (Check_Full_Access_Only): New procedure. (Process_Atomic_Independent_Shared_Volatile): Call to implement the new legality checks in C.6(8/2) and mark the entity last. (Analyze_Pragma) <Pragma_Atomic_Components>: Remove obsolete check. * sem_util.ads (Is_Atomic_Or_VFA_Object): Rename into... (Is_Full_Access_Object): ...this. (Is_Subcomponent_Of_Atomic_Object): Rename into... (Is_Subcomponent_Of_Full_Access_Object): ...this. * sem_util.adb (Inherit_Rep_Item_Chain): Use Present_In_Rep_Item. (Is_Atomic_Or_VFA_Object): Rename into... (Is_Full_Access_Object): ...this. (Is_Subcomponent_Of_Atomic_Object): Rename into... (Is_Subcomponent_Of_Full_Access_Object): ...this and adjust. * snames.ads-tmpl (Name_Full_Access_Only): New name of aspect. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for renaming. (promote_object_alignment): Likewise. (gnat_to_gnu_field): Likewise. Rename local variable and use specific qualifier in error message for Volatile_Full_Access. * gcc-interface/trans.c (lvalue_required_p): Likewise.
2020-10-23[Ada] Missing detection of unused with_clauseArnaud Charlet1-0/+9
gcc/ada/ * sem_ch4.adb (Complete_Object_Operation): Only mark entities referenced if we are compiling the extended main unit. * sem_attr.adb (Analyze_Attribute [Attribute_Tag]): Record a reference on the type and its scope.
2020-10-22[Ada] Implement AI12-0030: Stream attribute availabilitySteve Baird1-4/+10
gcc/ada/ * sem_util.ads, sem_util.adb: Declare and implement a new predicate, Derivation_Too_Early_To_Inherit. This function indicates whether a given derived type fails to inherit a given streaming-related attribute from its parent type because the declaration of the derived type precedes the corresponding attribute_definition_clause of the parent. * exp_tss.adb (Find_Inherited_TSS): Call Derivation_Too_Early_To_Inherit instead of unconditionally assuming that a parent type's streaming attribute is available for inheritance by an immediate descendant type. * sem_attr.adb (Stream_Attribute_Available): Call Derivation_Too_Early_To_Inherit instead of unconditionally assuming that a parent type's streaming attribute is available for inheritance by an immediate descendant type. * exp_attr.adb (Default_Streaming_Unavailable): A new predicate; given a type, indicates whether predefined (as opposed to user-defined) streaming operations for the type should be implemented by raising Program_Error. (Expand_N_Attribute_Reference): For each of the 4 streaming-related attributes (i.e., Read, Write, Input, Output), after determining that no user-defined implementation is available (including a Stream_Convert pragma), call Default_Streaming_Unavailable; if that call returns True, then implement the streaming operation as "raise Program_Error;".
2020-10-22[Ada] Reimplementation of accessibility checkingJustin Squirek1-3/+6
gcc/ada/ * checks.adb (Apply_Accessibility_Check): Modify condition to avoid flawed optimization and use Get_Accessibility over Extra_Accessibility. * exp_attr.adb: Remove inclusion of Exp_Ch2.adb. * exp_ch2.adb, exp_ch2.ads (Param_Entity): Moved to sem_util. * exp_ch3.ads (Init_Proc_Level_Formal): New function. * exp_ch3.adb (Build_Init_Procedure): Add extra accessibility formal for init procs when the associated type is a limited record. (Build_Initialization_Call): Add condition to handle propagation of the new extra accessibility paramter actual needed for init procs. (Init_Proc_Level_Formal): Created to fetch a the extra accessibility parameter associated with init procs if one exists. * exp_ch4.adb (Build_Attribute_Reference): Modify static check to be dynamic. * exp_ch6.adb (Add_Cond_Expression_Extra_Actual): Move logic used to expand conditional expressions used as actuals for anonymous access formals. (Expand_Call_Helper): Remove extranious accessibility calculation logic. * exp_util.adb: Remove inclusion of Exp_Ch2.adb. * par-ch3.adb (P_Array_Type_Definition): Properly set Aliased_Present on access definitions * sem_attr.adb (Resolve_Attribute): Replace instances for Object_Access_Level with Static_Accessibility_Level. * sem_ch13.adb (Storage_Pool): Replace instances for Object_Access_Level with Static_Accessibility_Level. * sem_ch6.adb (Check_Return_Construct_Accessibility): Replace instances for Object_Access_Level with Static_Accessibility_Level. * sem_ch9.adb (Analyze_Requeue): Replace instances for Object_Access_Level with Static_Accessibility_Level. * sem_res.adb (Check_Aliased_Parameter, Check_Allocator_Discrim_Accessibility, Valid_Conversion): Replace instances for Object_Access_Level with Static_Accessibility_Level. * sem_util.adb, sem_util.ads (Accessibility_Level_Helper): Created to centralize calculation of accessibility levels. (Build_Component_Subtype): Replace instances for Object_Access_Level with Static_Accessibility_Level. (Defining_Entity): Add extra parameter to dictate whether an error is raised or empty is return in the case of an irrelevant N. (Dynamic_Accessibility_Level): Rewritten to use Accessibility_Level_Helper. (Is_View_Conversion): Check membership against Etype to capture nodes like explicit dereferences which have types but are not expanded names or identifers. (Object_Access_LeveL): Removed. (Param_Entity): Moved from sem_util. (Static_Accessibility_Level): Created as a replacement to Object_Access_Level, it also uses Accessibility_Level_Helper for its implementation. * snames.ads-tmpl: Added new name for extra accessibility parameter in init procs.
2020-10-22[Ada] Fix oversight in Eval_Attribute for Bit_PositionEric Botcazou1-1/+1
gcc/ada/ * sem_attr.adb (Eval_Attribute): Fix oversight for Bit_Position.
2020-10-20[Ada] Implement AI12-0280 Making 'Old more flexibleSteve Baird1-2/+19
gcc/ada/ * sem_util.ads: Declare a new package, Old_Attr_Util, which in turn declares two more packages, Conditional_Evaluation and Indirect_Temps. Conditional_Evaluation provides a predicate for deciding whether a given 'Old attribute reference is eligible for conditional evaluation and, in the case where it is eligible, a function that constructs the Boolean-valued condition that is to be evaluated at run time in deciding whether to evaluate the attribute prefix. Indirect_Temps provides support for declaring a temporary which is only initialized conditionally; more specifically, an access type and a variable of that type are declared (unconditionally) and then the variable is (conditionally) initialized with an allocator. The existence of the access type and the pointer variable is hidden from clients, except that a predicate, Is_Access_Type_For_Indirect_Temp, is provided for identifying such access types. This is needed because we want such an access type to be treated like a "normal" access type (specifically with respect to finalization of allocated objects). Other parts of the compiler treat access types differently if Comes_From_Source is False, or if the secondary stack storage pool is used; this predicate is used to disable this special treatment. * sem_attr.adb (Uneval_Old_Msg): Improve message text to reflect Ada202x changes. (Analyze_Attribute): A previously-illegal 'Old attribute reference is accepted in Ada2020 if it is eligible for conditional evaluation. * sem_res.adb (Valid_Conversion): Do not treat a rewritten 'Old attribute like other rewrite substitutions. This makes a difference, for example, in the case where we are generating the expansion of a membership test of the form "Saooaaat'Old in Named_Access_Type"; in this case Valid_Conversion needs to return True (otherwise the expansion will be False - see the call site in exp_ch4.adb). * exp_attr.adb (Expand_N_Attribute_Reference): When expanding a 'Old attribute reference, test for the case where the reference is eligible for conditional evaluation. In that case, use the new "indirect temporary" mechanism provided by Sem_Util. * exp_prag.adb (Expand_Attributes_In_Consequence.Expand_Attributes): If Sem_Util.Indirect_Temp_Needed indicates that there could be correctness problems associated with the old expansion scheme for dealing with 'Old attributes in contract cases consequences, then we use the new "indirect temporary" mechanism provided by Sem_Util instead. We do not want to do this unconditionally. * sem_util.adb: Provide a body for the new Old_Attr_Util package. Further work is needed in several areas for correctness: - The function Is_Repeatedly_Evaluated does not deal with container aggregates yet. - The function Is_Known_On_Entry does not deal with interactions with the Global aspect. Each area where more work is needed is indicated with a "???" comment in the code; a more detailed description can be found there. Some optimization opportunties are similarly indicated with a "???" comment. * exp_ch3.adb (Freeze_Type): In deciding whether to generate expansion for the list controller of an access type, take the predicate Is_Access_Type_For_Indirect_Temp into account. If the predicate yields True, then generate the expansion. * exp_util.adb (Build_Allocate_Deallocate_Proc): We don't normally finalize allocated objects that are allocated on the secondary stack. Add an exception to this rule if the predicate Is_Access_Type_For_Indirect_Temp yields True. As a result of this exception, we have to deal with the fact that gigi expects a different parameter profile if we are using the secondary stack pool; the Pool and Alignment parameters must be omitted in this case.
2020-10-20[Ada] Make attribute Update an obsolescent featureClaire Dross1-0/+5
gcc/ada/ * sem_attr.adb (Analyze_Attribute): Emit a warning on 'Update when Warn_On_Obsolescent_Feature is set to True.
2020-10-16[Ada] Assorted style cleanupsPiotr Trojanek1-2/+2
gcc/ada/ * checks.adb, exp_aggr.adb, exp_attr.adb, exp_ch6.adb, freeze.adb, sem_aggr.adb, sem_attr.adb, sem_ch13.adb, sem_ch13.ads, sem_ch6.adb, sem_eval.adb, sem_util.adb: Fix style and typos.
2020-10-16[Ada] Improvements to implementation of Ada_2020 attribute ReduceEd Schonberg1-1/+22
gcc/ada/ * sem_attr.adb (Min_Max): Handle the case where attribute name (qualified by required type) appears as the reducer of a 'Reduce attribute reference. (Resolve_Attribute) <Reduce>: Handle properly the presence of a procedure or an attribute reference Min/Max as a reducer. * exp_attr.adb (Expand_Attribute_Reference) <Reduce>: New subprogram Build_Stat, to construct the combining statement which appears in the generated loop for Reduce, and which is either a function call when the reducer is a function or an attribute, or a procedure call when reducer is an appropriate procedure. BuilD_Stat is used both when the prefix of 'Reduce is a value sequence and when it is an object
2020-10-16[Ada] Add Max_Integer_Size attribute and couple of helper functionsEric Botcazou1-0/+8
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.
2020-07-27[Ada] Ada2020: wording of 'Image messagesBob Duff1-11/+6
gcc/ada/ * errout.ads, errout.adb (Error_Msg_Ada_2020_Feature): New procedure analogous to Error_Msg_Ada_2012_Feature. * sem_attr.adb (Analyze_Image_Attribute): Use Error_Msg_Ada_2012_Feature and Error_Msg_Ada_2020_Feature to indicate that Object'Image is allowed in Ada 2012, and that 'Image is allowed for any type in Ada 2020.
2020-07-27[Ada] Remove disabled codeArnaud Charlet1-13/+0
gcc/ada/ * sem_attr.adb (Resolve_Attribute): Remove dead code.
2020-07-27[Ada] Use membership tests in front-endArnaud Charlet1-82/+78
gcc/ada/ * aspects.adb, atree.adb, atree.ads, checks.adb, contracts.adb, einfo.adb, errout.adb, exp_aggr.adb, exp_attr.adb, exp_cg.adb, exp_ch11.adb, exp_ch2.adb, exp_ch3.adb, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch8.adb, exp_ch9.adb, exp_dbug.adb, exp_disp.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb, exp_put_image.adb, exp_smem.adb, exp_tss.adb, exp_unst.adb, exp_util.adb, freeze.adb, ghost.adb, gnat1drv.adb, inline.adb, lib-writ.adb, lib-xref-spark_specific.adb, lib-xref.adb, namet.adb, namet.ads, nlists.adb, par-ch10.adb, par-ch2.adb, par-ch3.adb, par-ch4.adb, par-ch5.adb, par-ch6.adb, par-prag.adb, par-util.adb, par_sco.adb, pprint.adb, repinfo.adb, restrict.adb, rtsfind.adb, scil_ll.adb, sem.adb, sem_aggr.adb, sem_attr.adb, sem_aux.adb, sem_cat.adb, sem_ch10.adb, sem_ch11.adb, sem_ch12.adb, sem_ch13.adb, sem_ch3.adb, sem_ch4.adb, sem_ch5.adb, sem_ch6.adb, sem_ch7.adb, sem_ch8.adb, sem_ch9.adb, sem_dim.adb, sem_disp.adb, sem_dist.adb, sem_elab.adb, sem_elim.adb, sem_eval.adb, sem_intr.adb, sem_mech.adb, sem_prag.adb, sem_res.adb, sem_scil.adb, sem_type.adb, sem_util.adb, sem_warn.adb, sinfo.adb, sinfo.ads, sprint.adb, styleg.adb, tbuild.adb, treepr.adb (Nkind_In, Nam_In, Ekind_In): Removed, replaced by membership tests.
2020-07-23[Ada] Ada2020: AI12-0027 Access values and unaliased componentArnaud Charlet1-0/+83
Access values should never designate unaliased components. This new feature is documented in AI12-0027-1. gcc/ada/ * sem_ch13.ads (Same_Representation): Renamed as Has_Compatible_Representation because now the order of the arguments are taken into account; its formals are also renamed as Target_Type and Operand_Type. * sem_ch13.adb (Same_Representation): Renamed and moved to place the routine in alphabetic order. * sem_attr.adb (Prefix_With_Safe_Accessibility_Level): New subprogram. (Resolve_Attribute): Check that the prefix of attribute Access does not have a value conversion of an array type. * sem_res.adb (Resolve_Actuals): Remove restrictive check on view conversions which required matching value of Has_Aliased_Components of formals and actuals. * exp_ch4.adb (Handle_Changed_Representation): Update call to Same_Representation. (Expand_N_Type_Conversion): Update call to Same_Representation. * exp_ch5.adb (Change_Of_Representation): Update call to Same_Representation. * exp_ch6.adb (Add_Call_By_Copy_Code): Update call to Same_Representation. (Expand_Actuals): Update call to Same_Representation. (Expand_Call_Helper): Update call to Same_Representation.
2020-07-16[Ada] Ada2020: AI12-0107 convention of By_Protected_ProcedureJavier Miranda1-4/+25
gcc/ada/ * exp_attr.adb (Has_By_Protected_Procedure_Prefixed_View): New subprogram. (Expand_Access_To_Protected_Op): Adding support for prefixed class-wide view with By_Protected_Procedure convention. * sem_attr.adb (Get_Convention): New subprogram. (Get_Kind): Adapted to use Get_Convention. * sem_ch4.adb (Try_By_Protected_Procedure_Prefixed_View): New subprogram. (Analyze_Selected_Component): Invoke Try_By_Protected_Procedure_Prefixed_View. * sem_util.ads (Is_By_Protected_Procedure): New subprogram. * sem_util.adb (Is_By_Protected_Procedure): New subprogram.
2020-07-15[Ada] Wrong resolution of 'access in protected subprogramJavier Miranda1-1/+23
gcc/ada/ * sem_attr.adb (Resolve_Attribute): Resolve overloaded N_Selected_Component prefix of 'Access. Required to handle overloaded prefixed view of protected subprograms.
2020-07-15[Ada] Extend static functionsArnaud Charlet1-1/+1
gcc/ada/ * inline.adb, inline.ads (Inline_Static_Expression_Function_Call): Renamed Inline_Static_Function_Call. * sem_ch13.adb (Analyze_Aspect_Static): Allow static intrinsic imported functions under -gnatX. * sem_util.ads, sem_util.adb (Is_Static_Expression_Function): Renamed Is_Static_Function. (Is_Static_Expression_Function_Call): Renamed Is_Static_Function_Call. * sem_ch6.adb, sem_elab.adb, sem_res.adb: Update calls to Is_Static_Function*. * sem_eval.adb (Fold_Dummy, Eval_Intrinsic_Call, Fold_Shift): New. (Eval_Call): Add support for intrinsic calls, code refactoring. (Eval_Entity_Name): Code refactoring. (Eval_Logical_Op): Update comment. (Eval_Shift): Call Fold_Shift. Update comments. * par-prag.adb (Par [Pragma_Extensions_Allowed]): Set Ada_Version to Ada_Version_Type'Last to handle Extensions_Allowed (On) consistently. * opt.ads (Extensions_Allowed): Update documentation. * sem_attr.adb: Update comment. * doc/gnat_rm/implementation_defined_pragmas.rst: Update documentation of Extensions_Allowed. * gnat_rm.texi: Regenerate.
2020-07-08[Ada] Minor reformatting and typo fixGary Dismukes1-7/+7
gcc/ada/ * sem_attr.adb: Remove hyphens in comments, plus minor code reformatting. * sem_ch13.adb: Fix typo (that => than). * sem_util.adb: Add hyphen in comment ("class-wide").
2020-07-08[Ada] Accept aspect Relaxed_Initialization on generic subprogramsPiotr Trojanek1-2/+10
gcc/ada/ * sem_attr.adb (Analyze_Attribute): Correct prefix of 'Result this prefix is a generic function but the enclosing aspect or pragma is attached to its instance. * sem_ch12.adb (Analyze_Generic_Subprogram_Declaration): Analyze generic subprogram formal parameters (including the implicit result of a generic function) and only then analyse its aspects, because with Relaxed_Initialization the aspect expression might refer to those formal parameters. * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Accept aspect on generic subprograms; install formal parameters of a generic subprogram but not formal parameters of the generic unit itself (the previous code was inspired by aspects Post and Depends, where both kinds of formals are allowed). * sem_util.ads (Enter_Name): Fix name of a subprogram referenced in comment.
2020-07-07[Ada] Simplify statically known Max_Size_In_Storage_Elements attribute in ↵Steve Baird1-3/+13
more cases gcc/ada/ * sem_attr.adb (Eval_Attribute): Generalize static evaluation of Size attribute references to also handle Max_Size_In_Storage_Elements references.
2020-07-07[Ada] Move generation of range checks for entry families to expanderEric Botcazou1-1/+1
gcc/ada/ * checks.ads (Expander Routines): Update the description of the Do_Range_Check mechanism. * checks.adb (Selected_Range_Checks): Fix typo. * exp_ch9.adb: Add with and use clause for Checks. (Actual_Index_Expression): Generate a range check if requested. (Entry_Index_Expression): Likewise. * sem_attr.adb (Resolve_Attribute) <Attribute_Count>: Call Apply_Scalar_Range_Check instead of Apply_Range_Check. * sem_ch9.adb (Analyze_Accept_Statement): Likewise. * sem_res.adb (Resolve_Entry): Likewise, after having set the actual index type on the prefix of the indexed component. (Resolve_Indexed_Component): Remove useless conditional construct.
2020-07-07[Ada] Remove extra checks for non-static context from resolving 'UpdatePiotr Trojanek1-3/+0
gcc/ada/ * sem_attr.adb (Resolve_Attribute): Do not call Check_Non_Static_Context.
2020-07-07[Ada] Set range checks for for 'Update on arrays in GNATprove expansionPiotr Trojanek1-22/+0
gcc/ada/ * exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Add scalar range checks for 'Update on arrays just like for 'Update on records. * sem_attr.adb (Analyze_Array_Component_Update): Do not set range checks for single-dimensional arrays. (Resolve_Attribute): Do not set range checks for both single- and multi- dimensional arrays.
2020-07-06[Ada] Fix evaluation of Enum_Rep applied to imported constantPiotr Trojanek1-0/+2
gcc/ada/ * sem_attr.adb (Eval_Attribute): Check if constant has an initialization expression.
2020-07-06[Ada] Set range checks flag on 'Update for GNATprove in expansionPiotr Trojanek1-28/+0
gcc/ada/ * exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Apply scalar range checks. * sem_attr.adb (Resolve_Attribute): Do not set scalar range checks when resolving attribute Update.
2020-07-06[Ada] Predicates and the current instance of a subtype (AI12-0068)Gary Dismukes1-10/+28
gcc/ada/ * sem_attr.adb (Analyze_Attribute, Attribute_Constrained): Issue a warning if the attribute prefix is a current instance reference within an aspect of a type or subtype. (Address_Checks): Replace test of Is_Object (Ent) with Is_Object_Reference (P) so that testing for current instances will be done. (Eval_Attribute): Add test for current instance reference, to ensure that we still fold array attributes when current instances are involved, since value prefixes are allowed for array attributes, and will now be excluded by Is_Object_Reference. * sem_util.ads (Is_Current_Instance_Reference_In_Type_Aspect): New exported query function. * sem_util.adb (Is_Object_Reference): Return False for the case where N is a current instance reference within an aspect_specification of a type or subtype (basically if the reference occurs within a predicate, invariant, or DIC aspect expression). (Is_Current_Instance_Reference_In_Type_Aspect): New function that tests whether a node is a reference to a current instance formal of a predicate, invariant, or Default_Initial_Condition (DIC) subprogram.
2020-07-06[Ada] Simplify implicit loading of Tasking_State in GNATprove_ModePiotr Trojanek1-15/+10
gcc/ada/ * sem_attr.adb (Analyze_Attribute): Reuse SPARK_Implicit_Load.
2020-07-06[Ada] Remove obsolete code in Eval_AttributeEric Botcazou1-10/+0
gcc/ada/ * sem_attr.adb (Eval_Attribute): Do not apply range checks in the case of 'Pos applied to an integer type here.
2020-06-19[Ada] Reject junk expressions in attribute UpdatePiotr Trojanek1-1/+6
2020-06-19 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * sem_attr.adb (Analyze_Attribute): Reject illegal positional component associations; fix syntax in comment about named component associations.
2020-06-19[Ada] Add comments about attribute 'Valid_Scalars on private tagged typesPiotr Trojanek1-0/+4
2020-06-19 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Add comment. * sem_attr.adb (Analyze_Attribute): Add ??? comment. * sem_util.ads (Valid_Scalars): This routine is only used for 'Valid_Scalars and not for 'Valid.
2020-06-18[Ada] Small cleanup in the attribute code of the expanderEric Botcazou1-0/+5
2020-06-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_attr.adb (Analyze_Attribute) <Asm_{In,Out}put>: Alphabetize. <Component_Size>: Add check for universal integer attribute. <Aft>, <Bit_Order>, <Definite>, <Max_Alignment_For_Allocation>, <Scalar_Storage_Order>: Raise Program_Error on them. * sem_attr.adb (Eval_Attribute) <Component_Size>: Add comment on the packed array case.
2020-06-18[Ada] Fix host/target confusion for attribute To_AddressEric Botcazou1-3/+3
2020-06-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * sem_attr.adb (Analyze_Attribute) <To_Address>: Use the address size of the target instead of the host when checking the value of a static expression. Also use standard idiom for exponentiation.
2020-06-18[Ada] Improve compile-time evaluation of value rangesEric Botcazou1-29/+142
2020-06-18 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * checks.adb (Compute_Range_For_Arithmetic_Op): New procedure to compute a range for an arithmetical operation extracted from... (Minimize_Eliminate_Overflows): ...here. Call it. (Determine_Range_Cache_O): New cache for Original_Node nodes. (Determine_Range): Call Compute_Range_For_Arithmetic_Op for all arithmetic expressions. Use Attribute_Id in lieu of Attribute_Name for attributes. Add handling for Range_Length alongside Length. Add specific handling for Alignment, Bit, First_Bit, Last_Bit, Max_Size_In_Storage_Elements, Position, Bit_Position, Component_Size, Object_Size, Size, Value_Size, Descriptor_Size. (Enable_Overflow_Check): Omit the check for Abs and Minus if the operand cannot be the largest negative number. (Selected_Length_Checks): Use Pos for Number_Dimensions. * exp_attr.adb (Expand_N_Attribute_Reference): Move compile-time handling of Bit_Position, Descriptor_Size, First_Bit, Last_Bit and Position to... * sem_attr.adb (Eval_Attribute): ...here. Move up Alignment for objects and use Compile_Time_Known_Attribute in this case too.
2020-06-17[Ada] Support aspect Relaxed_Initialization on private types and constantsPiotr Trojanek1-2/+1
2020-06-17 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * einfo.adb (Is_Relaxed_Initialization_State): Add reference to SPARK RM. * sem_attr.adb (Analyze_Attribute_Old_Result): Likewise. * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Reject aspect on completions of private types and deferred constants. * sem_util.ads, sem_util.adb (Has_Relaxed_Initialization): Adjust comments; support queries for constants.
2020-06-16[Ada] Declare expressionsBob Duff1-0/+8
2020-06-16 Bob Duff <duff@adacore.com> gcc/ada/ * par-ch4.adb (P_Case_Expression): Move to be local. (P_Declare_Expression): New parsing routine. (P_Unparen_Cond_Expr_Etc): New name for P_Unparen_Cond_Case_Quant_Expression which was missing one case in its name (iterated component association), and we're adding a new case (declare expression), so lets use "Etc" instead of trying to pack all those things into the name. Add call to P_Declare_Expression, and check for missing parens. (P_Expression_If_OK, P_Expression_Or_Range_Attribute_If_OK): Add Tok_Declare. * par.adb (P_Basic_Declarative_Items): Add parameter Declare_Expression so we can tailor the error message about incorrect bodies. (P_Case_Expression): Move to body. * par-ch3.adb (P_Basic_Declarative_Items): Tailor the error message about incorrect bodies. * par-ch7.adb (P_Package): Pass Declare_Expression => False to P_Basic_Declarative_Items. * sem.ads (In_Declare_Expr): Counter used to determine whether we are analyzing a declare_expression. Needed to give errors about things that are not allowed in declare_expression, such as the 'Access attribute. * sem.adb (Do_Analyze): Save/restore In_Declare_Expr. * sem_ch4.adb (Analyze_Expression_With_Actions): Give this node its own scope. That seems better in general, but it is necessary for declare_expressions. For example, an identifier declared in a declare_expression should not clash with the same identifier in an outer scope. If this is a declare_expression, indicated by Comes_From_Source, then check legality rules, and incr/decr In_Declare_Expr. * sem_aggr.adb (Resolve_Aggregate): Allow an applicable index constraint for a declare_expression, so if its expression is an array aggregate, it can have "others => ...". * sem_attr.adb (Analyze_Access_Attribute): Disallow these attributes in declare_expressions. Add comment to make it clear that Unrestricted_Access is included. * sinfo.ads, sinfo.adb, atree.ads, atree.adb: Remove the now-incorrect comment in sinfo.ads that says N_Expression_With_Actions has no proper scope. Add 17-parameter versions of Nkind_In. Remove the 16-parameter versions of Nkind_In.
2020-06-16[Ada] Check if attribute Passed_By_Reference is called on incomplete typesGhjuvan Lacambre1-0/+1
2020-06-16 Ghjuvan Lacambre <lacambre@adacore.com> gcc/ada/ * sem_attr.adb (Analyze_Attribute): Add Check_Not_Incomplete_Type call.
2020-06-15[Ada] T'Image calls T'Put_ImageBob Duff1-3/+1
2020-06-15 Bob Duff <duff@adacore.com> gcc/ada/ * exp_put_image.ads, exp_put_image.adb (Image_Should_Call_Put_Image): New function to determine whether the call to Put_Image should be generated. (Build_Image_Call): New procedure to generate the call to Put_Image. * exp_imgv.adb (Expand_Image_Attribute): Use underlying types to bypass privacy (only in Ada 2020). If Image_Should_Call_Put_Image is True (which happens only in Ada 2020), then call Build_Image_Call. * rtsfind.ads, rtsfind.adb: Add the necessary declarations in Ada.Strings.Text_Output.Buffers. * sem_attr.adb (Check_Image_Type): Enable the Ada 2020 case. * libgnat/a-stoufo.ads, libgnat/a-stoufo.adb: Use the less restrictive type that allows newline characters.
2020-06-15[Ada] Missing errors on aspect checkingArnaud Charlet1-3/+20
2020-06-15 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * sem_attr.adb (Eval_Attribute): Protect against previous errors. * sem_ch13.adb (Analyze_Aspect_Default_Value): Remove redundant error checking, handling in Analyze_Aspect_Specifications. (Analyze_Aspect_Specifications): Refine error messages on Default_[Component_]Value. (Check_Aspect_Too_Late): New procedure. (Rep_Item_Too_Late.Is_Derived_Type_With_Constraint): Remove, dead code. * aspects.ads (Is_Representation_Aspect): Default_Value is a representation aspect.
2020-06-15[Ada] Support aspect Relaxed_Initialization and attribute InitializedPiotr Trojanek1-0/+30
2020-06-15 Piotr Trojanek <trojanek@adacore.com> gcc/ada/ * aspects.ads (Aspect_Id): Add Aspect_Relaxed_Initialization. (Implementation_Defined_Aspect): Add new aspect. (Aspect_Argument): Add new aspect with Optional_Expression argument. (Is_Representation_Aspect): Add new aspect as a non-representation one. (Aspect_Names): Add name for the new aspect. (Aspect_Delay): Add new aspect as a non-delayed one. * sem_ch3.adb: Minor reformatting. * einfo.ads, einfo.adb (Is_Relaxed_Initialization_State): New query; reuses existing code for querying abstract state options. * exp_attr.adb (Expand_N_Attribute_Reference): For now ignore attribute 'Initialized. * sem_attr.adb (Analyze_Attribute_Old_Result): Allow attribute 'Result to be used in the aspect Relaxed_Initialization expression. (Analyze_Attribute): Analyze attribute 'Initialized; based on existing code for attribute 'Valid_Scalars. (Eval_Attribute): Do not expect attribute 'Initialized, just like attribute 'Valid_Scalars is not expected. * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): New routine. (Analyze_Aspect_Specifications): Analyze new aspect in a dedicated routine. (Check_Aspect_At_Freeze_Point): Do not expect new aspect. * sem_prag.adb (Analyze_Abstract_State): Support option Relaxed_Initialization on abstract states. * sem_util.ads, sem_util.adb (Has_Relaxed_Initialization): New query for the GNATprove backend. * snames.ads-tmpl (Snames): Add Name_Ids for the new aspect and attribute; add an Attribute_Id for the new attribute.
2020-06-15[Ada] Clean up error handling of 'ImageBob Duff1-30/+39
2020-06-15 Bob Duff <duff@adacore.com> gcc/ada/ * sem_attr.adb (Check_Image_Type): New procedure for checking the type, depending on language version. Disable the Ada 2020 support until the corresponding expander work is done. (Analyze_Image_Attribute): Call Check_Image_Type. Rearrange the code to be simplier and more logical. When P_Type is modified, modify P_Base_Type accordingly. * sem_util.adb (Is_Object_Image): Do not return False if the prefix is a type. X'Image should be considered an image of an object iff X is an object (albeit illegal pre-2020 if nonscalar).