aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_util.adb
AgeCommit message (Collapse)AuthorFilesLines
2020-11-30[Ada] Implement inheritance for Default_Initial_Condition and address other gapsGary Dismukes1-1/+9
gcc/ada/ * einfo.ads (Is_Partial_DIC_Procedure): New function. (Partial_DIC_Procedure): New procedure. * einfo.adb (Is_Partial_DIC_Procedure): New function to return whether a subprogram is a partial Default_Initial_Condition procedure by checking the name (to avoid adding a new field). (DIC_Procedure): Add a test that excludes partial DIC procedures from being returned. (Partial_DIC_Procedure): New procedure to return the partial DIC procedure of a type, if it has one (otherwise returns Empty). (Set_DIC_Procedure): Remove check for duplicate DIC procedures. * exp_aggr.adb (Gen_Assign): Generate a call to the type's DIC procedure in the case where an array component is default initialized (due to an association with a box). (Build_Record_Aggr_Code): For an extension aggregate, generate a call to the ancestor type's DIC procedure (if any) when the ancestor part is a subtype mark. For a record component association that was specified with a box (tested for by checking the new flag Was_Default_Init_Box_Association), generate a call to the component type's DIC procedure (if it has one). * exp_ch4.adb (Expand_N_Allocator): When the allocated object is default initialized and the designated type has a DIC aspect, generate a call to the DIC procedure. * exp_util.ads (Build_DIC_Call): Change the formal Obj_Id to name Obj_Name, and change its type from Entity_Id to Node_Id (and update comment). (Build_DIC_Procedure_Body): Add formal Partial_DIC, remove formal For_Freeze, and update comment accordingly. (Build_DIC_Procedure_Declaration): Add formal Partial_DIC and update comment. * exp_util.adb (Build_DIC_Call): Revised to use its Obj_Name (formerly Obj_Id) formal directly rather than calling New_Occurrence_Of on it, to allow arbitrary names to be passed rather than being limited to Entity_Ids. (Build_DIC_Procedure_Body): Call Add_Parent_DICs to generate checks for DICs associated with any parent types, implementing the required "additive" semantics for DICs. When building a DIC procedure body for a partial view (when Partial_DIC is True), call Add_Own_DIC when the type has its own DIC. In the case of "full" DIC procedures, a call is generated to any partial DIC procedure of the type (unless the procedure has a null body), along with checks for any DICs inherited by the full view. (Build_DIC_Procedure_Declaration): Add handling for partial DIC procedures. For the suffix of a regular DIC procedure's name, use "DIC" (instead of "Default_Initial_Condition"), and for the suffix of a partial DIC procedure's name, use "Partial_DIC". (Add_DIC_Check): Add the DIC pragma to the list of seen pragmas (Pragmas_Seen). (Add_Inherited_Tagged_DIC): Remove the formals Par_Typ, Deriv_Typ, and Obj_Id, and add formal Expr, which denotes DIC's expression. Remove the call to Replace_References (which is now done in Add_Inherited_DICs). (Add_Inherited_DICs): New procedure to locate a DIC pragma associated with a parent type, replace its references appropriately (such as any current instance references), and add a check for the DIC. (Add_Own_DIC): Add an Obj_Id formal to allow caller to pass the _init formal of the generated DIC procedure. (Add_Parent_DICs): New procedure to traverse a type's parents, looking for DICs associated with those and calling Add_Inherited_DICs to apply the appropriate DIC checks. (Is_Verifiable_DIC_Pragma): Treat pragmas that have an Empty first argument the same as a pragma without any arguments (returning False for that case). * exp_ch3.adb (Init_One_Dimension): Generate calls to the component's DIC procedure when needed. (Possible_DIC_Call): New function nested in Init_One_Dimension to build a call to the array component type's DIC-checking function when appropriate. (Build_Array_Init_Proc): The presence of a DIC on the component type is an additional condition for generating an init proc for an array type. (Build_Init_Statements): When the record component's type has a DIC, and the component declaration does not have an initialization expression, generate a call to the component type's DIC procedure. (Expand_N_Object_Declaration): Modify the call to Build_DIC_Call to pass a new occurrence of the object's defining id rather than the id itself. (Freeze_Type): Only build a type's DIC procedure (if it has one) for types that are not interfaces. * exp_spark.adb (Expand_SPARK_N_Freeze_Type): Remove From_Freeze actual and add a ??? comment. (Expand_SPARK_N_Object_Declaration): Modify call to Build_DIC_Call to pass a new occurrence of the object id rather than the object id itself. * sem_aggr.adb (Resolve_Record_Aggregate): Declare local flag Is_Box_Init_By_Default and set it in cases where the component association has a box and the component is being initialized by default (as opposed to initialized by an initialization expression associated with the component's declaration). (Add_Association): If the association has a box for a component initialized by default, the flag Was_Default_Init_Box_Association is set on the new component association (for later testing during expansion). (Get_Value): Reset Is_Box_Init_By_Default to False. * sem_ch3.adb (Build_Assertion_Bodies_For_Type): Rearrange code to build DIC procedure bodies for a (noninterface) type that Has_Own_DIC (for partial type views) or Has_DIC (for full type views) as appropriate. * sem_ch13.adb (Analyze_Aspect_Specifications, Aspect_Default_Initial_Condition): Add an extra argument to the DIC pragma to denote the type associated with the pragma (for use in Build_DIC_Procedure_Body). * sem_prag.adb (Analyze_Pragma): Allow two arguments for pragma Default_Initial_Condition. If not already present, add an extra argument denoting the type that the pragma is associated with. * sem_util.adb (Propagate_DIC_Attributes): Retrieve any partial DIC procedure associated with the type and add it to the type's list of subprograms (Subprograms_For_Type). * sinfo.ads (Was_Default_Init_Box_Association): New flag on N_Component_Association nodes. Add subprograms to get and set flag, as well as updating the documentation. * sinfo.adb (Was_Default_Init_Box_Association): New function to retrieve the corresponding flag (Flag14). (Set_Was_Default_Init_Box_Association): New procedure to set the corresponding flag (Flag14).
2020-11-30[Ada] Spurious visibility error in subprogram body in with_clauseEd Schonberg1-0/+7
gcc/ada/ * sem_util.adb (Enter_Name): When an inherited operation for a local derived type is hidden by an explicit declaration of a non-overloadable entity in the same scope, make the inherited operation non-visible to prevent its accidental use elsewhere.
2020-11-27[Ada] Reuse Append_New_Elmt where possiblePiotr Trojanek1-10/+2
gcc/ada/ * cstand.adb: Simplify with Append_New_Elmt. * sem_util.adb: Likewise.
2020-11-27[Ada] Implement AI12-0187 (Stable properties of abstract data types)Steve Baird1-3/+2
gcc/ada/ * snames.ads-tmpl: Define new Name_Stable_Properties Name_Id value. * aspects.ads, aspects.adb: Add new Aspect_Stable_Properties enumeration literal to Aspect_Id type. Add Class_Present parameter to Find_Aspect and related functions (Find_Value_Of_Aspect and Has_Aspect). * sem_util.adb (Has_Nontrivial_Precondition): Fix previously-latent bug uncovered by adding Class_Present parameter to Aspect.Find_Aspect. The code was wrong before, but with the change the bug was more likely to make a user-visible difference. * sem_ch6.adb (Analyze_Operator_Symbol): If a string literal like "abs" or "-" occurs in a Stable_Properties aspect specification, then it is to be interpreted as an operator symbol and not as a string literal. * sem_ch13.ads: Export new Parse_Aspect_Stable_Properties function, analogous to the existing Parse_Aspect_Aggregate exported procedure. * sem_ch13.adb: (Parse_Aspect_Stable_Properties): New function; analogous to existing Parse_Aspect_Aggregate. (Validate_Aspect_Stable_Properties): New procedure; analogous to existing Validate_Aspect_Aggregate. Called from the same case statement (casing on an Aspect_Id value) where Validate_Aspect_Aggregate is called. (Resolve_Aspect_Stable_Properties): New procedure; analogous to existing Resolve_Aspect_Aggregate. Called from the same two case statements (each casing on an Aspect_Id value) where Resolve_Aspect_Aggregate is called. (Analyze_Aspect_Specifications): Set Has_Delayed_Aspects and Is_Delayed_Aspect attributes for Aspect_Stable_Properties aspect specifications. (Check_Aspect_At_End_Of_Declarations): The syntactic "expression" for a Stable_Properties aspect specification is not semantically an expression; it doesn't have a type. Thus, force T to be empty in this case. * contracts.adb (Expand_Subprogram_Contract): Add call to new local procedure, Expand_Subprogram_Contract.Add_Stable_Property_Contracts, which generates Postcondition pragmas corresponding to stable property checks.
2020-11-26[Ada] Remove duplicated calls to Set_EntityPiotr Trojanek1-2/+0
gcc/ada/ * sem_ch4.adb (Indicate_Name_And_Type): Fix whitespace in comment. * sem_res.adb (Resolve_Call): Remove redundant parens. * sem_util.adb (Set_Entity_With_Checks): Remove extra call to Set_Entity.
2020-11-26[Ada] Reuse Is_Concurrent_Type when detecting protected or task typesPiotr Trojanek1-1/+1
gcc/ada/ * exp_ch13.adb, exp_ch9.adb, sem_ch8.adb, sem_util.adb: Replace a combination of Is_Protected_Type and Is_Task_Type by Is_Concurrent_Type.
2020-11-26[Ada] Pass base type to Set_Has_Own_InvariantsBob Duff1-1/+1
gcc/ada/ * freeze.adb (Freeze_Array_Type): Remove propagation of Has_Own_Invariants to the first subtype. This is a no-op, because the current (incorrect) version of Has_Own_Invariants calls Base_Type. * sem_prag.adb, sem_util.adb: Pass the base type to Set_Has_Own_Invariants.
2020-11-25[Ada] Document attribute Has_Tagged_Values in GNAT RMPiotr Trojanek1-1/+1
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] Minimize side-effect removal in GNATprove modeYannick Moy1-0/+2
gcc/ada/ * exp_util.adb (Remove_Side_Effects): Only remove side-effects in GNATprove mode when this is useful. * sem_res.adb (Set_Slice_Subtype): Make sure in GNATprove mode to define the Itype when needed, so that run-time errors can be analyzed. * sem_util.adb (Enclosing_Declaration): Correctly take into account renaming declarations.
2020-11-24[Ada] Reuse Is_Packed_Array where possiblePiotr Trojanek1-2/+1
gcc/ada/ * exp_attr.adb, exp_ch4.adb, exp_intr.adb, sem_ch8.adb, sem_res.adb, sem_type.adb, sem_util.adb: Reuse Is_Packed_Array.
2020-11-24[Ada] Cleanup expansion of attribute ConstrainedPiotr Trojanek1-1/+1
gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference): Replace calls to Sloc with a local constant Loc; remove call to Analyze_And_Resolve and return, which is exactly what happens anyway (and other branches in the Constrained declare block appear to rely on analysis, resolution and returning happening in all cases). * sem_util.adb: Remove useless parens.
2020-11-24[Ada] Recognize delta and extension aggregates as objectsPiotr Trojanek1-1/+4
gcc/ada/ * sem_util.adb (Is_Object_Reference): Delta and extension aggregates are objects.
2020-11-24[Ada] Handle correctly current instance of PO in local subprogram GlobalYannick Moy1-15/+28
gcc/ada/ * sem_prag.adb (Analyze_Global_Item): Handle specially the current instance of a PO. * sem_util.ads (Is_Effectively_Volatile, Is_Effectively_Volatile_For_Reading): Add parameter Ignore_Protected. * sem_util.adb (Is_Effectively_Volatile, Is_Effectively_Volatile_For_Reading): Add parameter Ignore_Protected to compute the query results ignoring protected objects/types. (Is_Effectively_Volatile_Object, Is_Effectively_Volatile_Object_For_Reading): Adapt to new signature.
2020-10-23[Ada] Further Ada 2020 work on accessibility checkingJustin Squirek1-189/+383
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-17/+18
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] Iterative patch for accessibility cleanupJustin Squirek1-20/+85
gcc/ada/ * sem_util.adb (Accessibility_Call_Helper): In the selected component case, test if a prefix is a function call and whether the subprogram call is not being used in its entirety and use the Innermost_Master_Scope_Depth in that case. (Innermost_Master_Scope_Depth): Test against the node_par instead of its identifier to avoid misattributing unnamed blocks as not being from source. (Function_Call_Level): Add calculation for whether a subprogram call is initializing an object in its entirety. (Subprogram_Call_Level): Renamed to Function_Call_Level.
2020-10-22[Ada] AI12-0211: Consistency of inherited nonoverridable aspectsSteve Baird1-1/+241
gcc/ada/ * aspects.ads: Introduce the subtype Nonoverridable_Aspect_Id, whose Static_Predicate reflects the list of nonoverridable aspects given in Ada RM 13.1.1(18.7). * sem_util.ads, sem_util.adb: Add two new visible subprograms, Check_Inherited_Nonoverridable_Aspects and Is_Confirming. The former is used to check the consistency of inherited nonoverridable aspects from multiple sources. The latter indicates whether two aspect specifications for a nonoverridable aspect are confirming. Because of compatibility concerns in compiling QGen, Is_Confirming always returns True if Relaxed_RM_Semantics (i.e., -gnatd.M) is specified. * sem_ch3.adb (Derived_Type_Declaration): Call new Check_Inherited_Nonoverridable_Aspects procedure if interface list is non-empty. * sem_ch9.adb (Check_Interfaces): Call new Check_Inherited_Nonoverridable_Aspects procedure if interface list is non-empty. * sem_ch13.adb (Analyze_Aspect_Specifications): When an explicit aspect specification overrides an inherited nonoverridable aspect, check that the explicit specification is confirming.
2020-10-22[Ada] Implement AI12-0280's interactions with container aggregatesSteve Baird1-56/+91
gcc/ada/ * sem_util.adb (Is_Container_Aggregate): A new local predicates which indicates whether a given expression is a container aggregate. The implementation of this function is incomplete; in the unusual case of a record aggregate (i.e., not a container aggregate) of a type whose Aggregate aspect is specified, the function will incorrectly return True. (Immediate_Context_Implies_Is_Potentially_Unevaluated): Improve handling of aggregate components. (Is_Repeatedly_Evaluated): Test for container aggregate components along with existing test for array aggregate components.
2020-10-22[Ada] Wrong accessibility for conversion to named accessJustin Squirek1-0/+7
gcc/ada/ * sem_util.adb (Accessibility_Level_Helper): Conversions to named access types get the level associated with the named access type.
2020-10-22[Ada] Implement AI12-0030: Stream attribute availabilitySteve Baird1-0/+66
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-539/+620
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] AI12-0307: uniform resolution rules for aggregatesEd Schonberg1-0/+21
gcc/ada/ * sem_util.ads, sem_util.adb (Check_Ambiguous_Aggregate): When a subprogram call is found to be ambiguous, check whether ambiguity is caused by an aggregate actual. and indicate that it should carry a type qualification. * sem_ch4.adb (Traverse_Hoonyms, Try_Primitive_Operation): Call it. * sem_res.adb (Report_Ambiguous_Argument): Call it.
2020-10-21[Ada] Basic support for 128-bit typesEric Botcazou1-5/+15
gcc/ada/ * Makefile.rtl (GNATRTL_128BIT_PAIRS): New variable. (GNATRTL_128BIT_OBJS): Likewise. (Windows): In 64-bit mode, add the former to LIBGNAT_TARGET_PAIRS and the latter to EXTRA_GNATRTL_NONTASKING_OBJS. (x86_64/linux): Likewise, but unconditionally. (GNATRTL_NONTASKING_OBJS): Add s-aridou, s-exponn, s-expont, s-exponu. * ada_get_targ.adb (Get_Long_Long_Long_Size): New function. * checks.adb (Apply_Arithmetic_Overflow_Strict): Use Integer_Type_For to find an appropriate integer type; if it does not exist and the max integer size is larger than 64, use the 128-bit arithmetic routines. * cstand.adb (Create_Standard): Build Standard_Long_Long_Long_Integer and its base type. Use it for Etype of Any_Integer, Any_Modular and Any_Numeric. Use its size for Build Standard_Long_Long_Long_Unsigned and Universal_Integer. (Print_Standard): Print Long_Long_Long_Integer. * exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Mod>: Adjust comment. * exp_ch3.adb (Simple_Init_Initialize_Scalars_Type): Deal with 128-bit types. * exp_ch4.adb (Expand_Array_Comparison): Likewise. (Expand_N_Op_Expon): Likewise. (Narrow_Large_Operation): Likewise. * exp_dbug.adb (Bounds_Match_Size): Handle 128-bit size. * exp_fixd.adb (Build_Double_Divide_Code): Use RE_Double_Divide64. * exp_intr.adb (Expand_Binary_Operator_Call): Handle 128-bit size. * exp_pakd.ads (E_Array): Extend range to 127. (Bits_Id): Fill in up to 127. (Get_Id): Likewise. (GetU_Id): Likewise. (Set_Id): Likewise. (SetU_Id): Likewise. * exp_pakd.adb (Revert_Storage_Order): Handle 128-bit size. * exp_util.adb (Integer_Type_For): Likewise. (Small_Integer_Type_For): Likewise. * fname.adb (Is_Predefined_File_Name): Do not return False for names larger than 12 characters if they start with "s-". * freeze.adb (Adjust_Esize_For_Alignment): Change the maximum value to System_Max_Integer_Size. (Check_Suspicious_Modulus): Adjust comment. (Freeze_Entity): Likewise. * get_targ.ads (Get_Long_Long_Long_Size): New function. * get_targ.adb (Get_Long_Long_Long_Size): Likewise. (Width_From_Size): Deal with 128-bit size. * gnat1drv.adb (Adjust_Global_Switches): Deal with 128-bit types. * impunit.adb (Get_Kind_Of_File): Bump buffer size. Accept files with 13 characters if they start with 's'. Compare slice of Buffer. (Not_Impl_Defined_Unit): Accept files with 13 characters if they start with 's'. * krunch.ads: Document length for 128-bit support units. * krunch.adb (Krunch): Set length to 9 for 128-bit support units. * layout.adb (Layout_Type): Use System_Max_Integer_Size as alignment limit. * rtsfind.ads (RTU_Id): Add System_Arith_128, System_Compare_Array_Signed_128, System_Compare_Array_Unsigned_128, System_Exn_LLLI, System_Exp_LLLU, System_Pack_[65..127]. (RE_Id): Add RE_Integer_128, RE_Unsigned_128, RE_Add_With_Ovflo_Check128 RE_Multiply_With_Ovflo_Check128, RE_Subtract_With_Ovflo_Check128, RE_Bswap_128, RE_Compare_Array_S128, RE_Compare_Array_U128, RE_Exn_Long_Long_Long_Integer, RE_Exp_Long_Long_Long_Integer, RE_Exp_Long_Long_Long_Unsigned, RE_Bits_[65-127], RE_Get_[65-127], RE_Set_[65-127], RE_IS_Is16, RE_IS_Iu16, RE_Integer_128 and RE_Unsigned_128. Rename RE_Add_With_Ovflo_Check, RE_Double_Divide, RE_Multiply_With_Ovflo_Check, RE_Scaled_Divide and RE_Subtract_With_Ovflo_Check. Remove RE_IS_Iz1, RE_IS_Iz2, RE_IS_Iz4, RE_IS_Iz8, RE_Long_Unsigned, RE_Short_Unsigned, RE_Short_Short_Unsigned (RE_Unit_Table): Likewise. * sem_aux.adb (Corresponding_Unsigned_Type): Deal with a size equal to that of Standard_Long_Long_Long_Integer. (First_Subtype): Deal with Standard_Long_Long_Long_Integer'Base. * sem_ch13.adb (Analyze_Attribute_Definition_Clause) <Attribute_Size>: Check the size against powers of 2 and System_Max_Integer_Size for objects as well. (Set_Enum_Esize): Deal with 128-bit bounds. * sem_ch3.adb (Set_Modular_Size): Handle 128-bit size. (Modular_Type_Declaration): Deal with 128-bit types. (Signed_Integer_Type_Declaration): Support derivation from Standard_Long_Long_Long_Integer. * sem_ch4.adb (Analyze_Mod): Handle 128-bit modulus. * sem_intr.adb: Add with and use clauses for Ttypes. (Check_Shift): Handle 128-bit size and modulus. * sem_prag.adb (Analyze_Pragma) <Pragma_Initialize_Scalars>: Deal with Signed_128 and Unsigned_128. (Analyze_Integer_Value): Handle 128-bit size. * sem_util.ads (Addressable): Adjust description. * sem_util.adb (Addressable): Return true for 128 if the system supports 128 bits. (Set_Invalid_Binder_Values): Deal with Signed_128 and Unsigned_128. * set_targ.ads (Long_Long_Long_Size): New variable. * set_targ.adb (S_Long_Long_Long_Size): New constant. (DTN): Add entry for S_Long_Long_Long_Size. (DTV): Add entry for Long_Long_Long_Size. (Set_Targ): Set Long_Long_Long_Size. * snames.ads-tmpl (Name_Max_Integer_Size): New attribute name. (Name_Signed_128): New scalar name. (Name_Unsigned_128): Likewise. (Scalar_Id): Adjust. (Integer_Scalar_Id): Likewise. (Attribute_Id): Add Attribute_Max_Integer_Size. * stand.ads (Standard_Entity_Type): Add S_Long_Long_Long_Integer. (Standard_Long_Long_Long_Integer): New renaming. (Universal_Integer): Adjust description. (Standard_Long_Long_Long_Unsigned): New variable. * switch-c.adb (Scan_Front_End_Switches): Deal with -gnate128. * ttypes.ads (Standard_Long_Long_Long_Integer_Size): New variable. (Standard_Long_Long_Long_Integer_Width): Likewise. (System_Max_Integer_Size): Turn into variable. (System_Max_Binary_Modulus_Power): Likewise. * uintp.ads (Uint_127): New constant. * uintp.adb (UI_Power_2): Extednd to 128. (UI_Power_10): Likewise. (UI_Expon): Deal with exponent up to 128 specially. * usage.adb (Write_Switch_Char): Print -gnate128 switch. * libgnat/a-tifiio.adb (Put_Scaled): Call Scaled_Divide64. * libgnat/interfac__2020.ads (Integer_128): New integer type. (Unsigned_128): New modular type. (Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, Rotate_Right): New intrinsic functions operating on it. * libgnat/s-aridou.ads, libgnat/s-aridou.adb: New generic package. * libgnat/s-arit64.ads, libgnat/s-arit64.adb: Instantiate System.Arithmetic_Double. * libgnat/s-arit128.ads, libgnat/s-arit128.adb: Likewise. * libgnat/s-bytswa.ads: Add with clause for Interfaces, use subtypes of unsigned types defined in Interfaces and add Bswap_128. * libgnat/s-casi128.ads, libgnat/s-casi128.adb: New package. * libgnat/s-caun128.ads, libgnat/s-caun128.adb: Likewise. * libgnat/s-exnint.ads: Instantiate System.Exponn. * libgnat/s-exnint.adb: Add pragma No_Body. * libgnat/s-exnlli.ads: Instantiate System.Exponn. * libgnat/s-exnlli.adb: Add pragma No_Body. * libgnat/s-exnllli.ads: Instantiate System.Exponn. * libgnat/s-expint.ads: Likewise. * libgnat/s-expint.adb: Add pragma No_Body. * libgnat/s-explli.ads: Instantiate System.Exponn. * libgnat/s-explli.adb: Add pragma No_Body. * libgnat/s-expllli.ads: Instantiate System.Exponn. * libgnat/s-explllu.ads: Instantiate System.Exponu. * libgnat/s-expllu.ads: Likewise. * libgnat/s-expllu.adb: Add pragma No_Body. * libgnat/s-exponn.ads, libgnat/s-exponn.adb: New generic function. * libgnat/s-expont.ads, libgnat/s-expont.adb: Likewise. * libgnat/s-exponu.ads, libgnat/s-exponu.adb: Likewise. * libgnat/s-expuns.ads, libgnat/s-expuns.adb: Likewise. * libgnat/s-pack65.ads, libgnat/s-pack65.adb: New package. * libgnat/s-pack66.ads, libgnat/s-pack66.adb: New package. * libgnat/s-pack67.ads, libgnat/s-pack67.adb: New package. * libgnat/s-pack68.ads, libgnat/s-pack68.adb: New package. * libgnat/s-pack69.ads, libgnat/s-pack69.adb: New package. * libgnat/s-pack70.ads, libgnat/s-pack70.adb: New package. * libgnat/s-pack71.ads, libgnat/s-pack71.adb: New package. * libgnat/s-pack72.ads, libgnat/s-pack72.adb: New package. * libgnat/s-pack73.ads, libgnat/s-pack73.adb: New package. * libgnat/s-pack74.ads, libgnat/s-pack74.adb: New package. * libgnat/s-pack75.ads, libgnat/s-pack75.adb: New package. * libgnat/s-pack76.ads, libgnat/s-pack76.adb: New package. * libgnat/s-pack77.ads, libgnat/s-pack77.adb: New package. * libgnat/s-pack78.ads, libgnat/s-pack78.adb: New package. * libgnat/s-pack79.ads, libgnat/s-pack79.adb: New package. * libgnat/s-pack80.ads, libgnat/s-pack80.adb: New package. * libgnat/s-pack81.ads, libgnat/s-pack81.adb: New package. * libgnat/s-pack82.ads, libgnat/s-pack82.adb: New package. * libgnat/s-pack83.ads, libgnat/s-pack83.adb: New package. * libgnat/s-pack84.ads, libgnat/s-pack84.adb: New package. * libgnat/s-pack85.ads, libgnat/s-pack85.adb: New package. * libgnat/s-pack86.ads, libgnat/s-pack86.adb: New package. * libgnat/s-pack87.ads, libgnat/s-pack87.adb: New package. * libgnat/s-pack88.ads, libgnat/s-pack88.adb: New package. * libgnat/s-pack89.ads, libgnat/s-pack89.adb: New package. * libgnat/s-pack90.ads, libgnat/s-pack90.adb: New package. * libgnat/s-pack91.ads, libgnat/s-pack91.adb: New package. * libgnat/s-pack92.ads, libgnat/s-pack92.adb: New package. * libgnat/s-pack93.ads, libgnat/s-pack93.adb: New package. * libgnat/s-pack94.ads, libgnat/s-pack94.adb: New package. * libgnat/s-pack95.ads, libgnat/s-pack95.adb: New package. * libgnat/s-pack96.ads, libgnat/s-pack96.adb: New package. * libgnat/s-pack97.ads, libgnat/s-pack97.adb: New package. * libgnat/s-pack98.ads, libgnat/s-pack98.adb: New package. * libgnat/s-pack99.ads, libgnat/s-pack99.adb: New package. * libgnat/s-pack100.ads, libgnat/s-pack100.adb: New package. * libgnat/s-pack101.ads, libgnat/s-pack101.adb: New package. * libgnat/s-pack102.ads, libgnat/s-pack102.adb: New package. * libgnat/s-pack103.ads, libgnat/s-pack103.adb: New package. * libgnat/s-pack104.ads, libgnat/s-pack104.adb: New package. * libgnat/s-pack105.ads, libgnat/s-pack105.adb: New package. * libgnat/s-pack106.ads, libgnat/s-pack106.adb: New package. * libgnat/s-pack107.ads, libgnat/s-pack107.adb: New package. * libgnat/s-pack108.ads, libgnat/s-pack108.adb: New package. * libgnat/s-pack109.ads, libgnat/s-pack109.adb: New package. * libgnat/s-pack110.ads, libgnat/s-pack110.adb: New package. * libgnat/s-pack111.ads, libgnat/s-pack111.adb: New package. * libgnat/s-pack112.ads, libgnat/s-pack112.adb: New package. * libgnat/s-pack113.ads, libgnat/s-pack113.adb: New package. * libgnat/s-pack114.ads, libgnat/s-pack114.adb: New package. * libgnat/s-pack115.ads, libgnat/s-pack115.adb: New package. * libgnat/s-pack116.ads, libgnat/s-pack116.adb: New package. * libgnat/s-pack117.ads, libgnat/s-pack117.adb: New package. * libgnat/s-pack118.ads, libgnat/s-pack118.adb: New package. * libgnat/s-pack119.ads, libgnat/s-pack119.adb: New package. * libgnat/s-pack120.ads, libgnat/s-pack120.adb: New package. * libgnat/s-pack121.ads, libgnat/s-pack121.adb: New package. * libgnat/s-pack122.ads, libgnat/s-pack122.adb: New package. * libgnat/s-pack123.ads, libgnat/s-pack123.adb: New package. * libgnat/s-pack124.ads, libgnat/s-pack124.adb: New package. * libgnat/s-pack125.ads, libgnat/s-pack125.adb: New package. * libgnat/s-pack126.ads, libgnat/s-pack126.adb: New package. * libgnat/s-pack127.ads, libgnat/s-pack127.adb: New package. * libgnat/s-rannum.ads (Random): New function returning 128-bit. * libgnat/s-rannum.adb (Random): Implement it. * libgnat/s-scaval.ads: Add with clause for Interfaces, use subtypes of unsigned types defined in Interfaces. * libgnat/s-scaval.adb: Add use clause for Interfaces. * libgnat/s-scaval__128.ads, libgnat/s-scaval__128.adb: New package. * libgnat/s-unstyp.ads (Long_Long_Long_Unsigned): New modular type. (Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, Rotate_Right): New intrinsic functions operating on it. gcc/testsuite/ * gnat.dg/multfixed.adb: Update expected exception message.
2020-10-21[Ada] Fix typos and style in comments related to Default_Initial_ConditionPiotr Trojanek1-1/+1
gcc/ada/ * einfo.ads, sem_ch3.adb, sem_util.adb: Fix comments.
2020-10-20[Ada] Refine result type of Get_AccessibilityPiotr Trojanek1-1/+1
gcc/ada/ * sem_util.ads, sem_util.adb (Get_Accessibility): Refine result type from Node_Id to Entity_Id.
2020-10-20[Ada] Replace low-level Ekind membership tests with high-level Is_FormalPiotr Trojanek1-1/+1
gcc/ada/ * einfo.adb, exp_attr.adb, sem_ch13.adb, sem_util.adb: Use Is_Formal where possible.
2020-10-20[Ada] Implement AI12-0280 Making 'Old more flexibleSteve Baird1-0/+909
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] Fix comments as volatility properties can apply to objectsYannick Moy1-1/+1
gcc/ada/ * sem_util.adb, sem_util.ads: Comment fix.
2020-10-20[Ada] Support for new aspect Subprogram_Variant on recursive subprogramsPiotr Trojanek1-0/+14
gcc/ada/ * aspects.ads: Introduce Subprogram_Variant aspect with the following properties: GNAT-specific, with mandatory expression, not a representation aspect, never delayed. * contracts.adb (Expand_Subprogram_Contract): Mention new aspect in the comment. (Add_Contract_Item): Support addition of pragma Subprogram_Variant to N_Contract node. (Analyze_Entry_Or_Subprogram_Contract): Mention new aspect in the comment; add pragma Subprogram_Variant to N_Contract node. (Build_Postconditions_Procedure): Adapt call to Insert_Before_First_Source_Declaration, which is now reused in expansion of new aspect. (Process_Contract_Cases_For): Also process Subprogram_Variant, which is stored in N_Contract node together with Contract_Cases. * contracts.ads (Analyze_Entry_Or_Subprogram_Contract): Mention new aspect in the comment. (Analyze_Entry_Or_Subprogram_Body_Contract): Likewise. * einfo.adb (Get_Pragma): Support retrieval of new pragma. * einfo.ads (Get_Pragma): Likewise. * exp_ch6.adb (Check_Subprogram_Variant): New routine for emitting call to check Subprogram_Variant expressions at run time. (Expand_Call_Helper): Check Subprogram_Variant expressions at recursive calls. * exp_prag.adb (Make_Op): Moved from expansion of pragma Loop_Variant to Exp_Util, so it is now reused for expansion of pragma Subprogram_Variant. (Process_Variant): Adapt call to Make_Op after moving it to Exp_Util. (Expand_Pragma_Subprogram_Variant): New routine. * exp_prag.ads (Expand_Pragma_Subprogram_Variant): Likewise. * exp_util.adb (Make_Variant_Comparison): Moved from Exp_Prag (see above). * exp_util.ads (Make_Variant_Comparison): Likewise. * inline.adb (Remove_Aspects_And_Pragmas): Handle aspect/pragma Subprogram_Variant just like similar contracts. * par-prag.adb (Prag): Likewise. * sem.adb (Insert_Before_First_Source_Declaration): Moved from Contracts (see above). * sem.ads (Insert_Before_First_Source_Declaration): Likewise. * sem_ch12.adb: Mention new aspect in the comment about "Implementation of Generic Contracts", just like similar aspects are mentioned there. * sem_ch13.adb (Insert_Pragma): Mention new aspect in the comment, because this routine is now used for Subprogram_Variant just like for other similar aspects. (Analyze_Aspect_Specifications): Mention new aspect in comments; it is handled just like aspect Contract_Cases. (Check_Aspect_At_Freeze_Point): Do not expect aspect Subprogram_Variant just like we don't expect aspect Contract_Cases. * sem_prag.adb (Ensure_Aggregate_Form): Now also used for pragma Subprogram_Variant, so update comment. (Analyze_Pragma): Add initial checks for pragma Subprogram_Variant. (Analyze_Subprogram_Variant_In_Decl_Part): New routine with secondary checks on the new pragma. (Sig_Flags): Handle references within pragma Subprogram_Variant expression just like references in similar pragma Contract_Cases. (Is_Valid_Assertion_Kind): Handle Subprogram_Variant just like other similar contracts. * sem_prag.ads (Analyze_Subprogram_Variant_In_Decl_Part): New routine. * sem_res.adb (Same_Or_Aliased_Subprograms): Moved to Sem_Util, so it can be reused for detection of recursive calls where Subprogram_Variant needs to be verified. * sem_util.adb (Is_Subprogram_Contract_Annotation): Handle new Subprogram_Variant annotation just like other similar annotations. (Same_Or_Aliased_Subprograms): Moved from Sem_Res (see above). * sem_util.ads (Is_Subprogram_Contract_Annotation): Mention new aspect in the comment. (Same_Or_Aliased_Subprograms): Moved from Sem_Res (see above). * sinfo.ads (N_Contract): Document handling of Subprogram_Variant. * snames.ads-tmpl: Add name for the internally generated procedure with checks for Subprogram_Variant expression, name for the new aspect and new pragma corresponding to aspect Subprogram_Variant.
2020-10-19[Ada] Expanded names in ghost assignmentsBob Duff1-16/+12
gcc/ada/ * ghost.adb (Whole_Object_Ref): New function to compute the name of the whole object. (Mark_And_Set_Ghost_Assignment): Rewrite to use Whole_Object_Ref. We need to partly analyze the left-hand side in order to distinguish expanded names and record components. * lib-xref.ads, lib-xref.adb (Deferred_References): Move table to body, and add Defer_Reference to update the table, avoiding duplicates. (Generate_Reference): Avoid duplicates. * sem_ch8.ads, sem_ch8.adb (Find_Direct_Name): Remove _OK parameters, which are no longer needed. Ignore errors in Ignore_Errors mode. * sem_util.ads, sem_util.adb (Preanalyze_Without_Errors): Make this public, so we can call it from Ghost. * errout.ads, scng.adb, sem_prag.adb: Minor.
2020-10-16[Ada] Assorted style cleanupsPiotr Trojanek1-1/+1
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] Constants no longer synchronised if they are access-to-variableChris Martin1-2/+15
gcc/ada/ * sem_util.ads, sem_util.adb (Is_Access_Variable): New function. (Is_Synchronized_Object): Call new function when determining if a constant can be regarded as synchronized.
2020-10-16[Ada] Detect qualified type names for AI12-0027Piotr Trojanek1-1/+1
gcc/ada/ * sem_util.adb (Is_View_Conversion): Detect qualified types. * sem_util.ads (Is_Actual_In_Out_Parameter): Fix style in comment.
2020-10-16[Ada] SPARK: update for effectively volatile types and objectsYannick Moy1-12/+101
gcc/ada/ * sem_prag.adb (Analyze_Global_In_Decl_Part): Update check to reject volatile object for reading. * sem_res.adb (Resolve_Actuals, Resolve_Entity_Name): Update check to reject volatile object for reading. * sem_util.adb, sem_util.ads (Check_Nonvolatile_Function_Profile, Has_Effectively_Volatile_Profile): Detect use of volatile object for reading. (Has_Enabled_Property): Accept constants as well. (Is_Effectively_Volatile_For_Reading): New function based on existing Is_Effectively_Volatile. (Is_Effectively_Volatile_Object_For_Reading): Adapted from the existing Is_Effectively_Volatile_Object, using a shared implementation in Is_Effectively_Volatile_Object_Shared.
2020-10-15[Ada] Fix access to uninitialized global variable when emitting errorPiotr Trojanek1-1/+1
gcc/ada/ * sem_util.adb (Bad_Predicated_Subtype_Use): Emit an unconditional error, not a conditional warning.
2020-10-15[Ada] Code cleanupArnaud Charlet1-11/+2
gcc/ada/ * sem_util.adb (Enter_Name): Remove unnecessary conditions in Enter_Name that come from the beginning of times.
2020-10-15[Ada] AI12-0385 Predefined shifts and rotates should be staticArnaud Charlet1-4/+9
gcc/ada/ * Makefile.rtl: Add target pair for interfac.ads. * libgnat/interfac.ads: Add a comment. * libgnat/interfac__2020.ads: New, used for bootstrap purposes. * sem_util.adb (Is_Static_Function): Always return False for pre Ada 2020 to e.g. ignore the Static aspect in Interfaces for Ada < 2020.
2020-09-03Look at fullest view when checking for static types in unnestingArnaud Charlet1-0/+73
When seeing if any bound involved in a type is an uplevel reference, we must look at the fullest view of a type, since that's what the backends will do. Similarly for private types. We introduce Get_Fullest_View for that purpose. * sem_util.ads, sem_util.adb (Get_Fullest_View): New procedure. * exp_unst.adb (Check Static_Type): Do all processing on fullest view of specified type.
2020-07-27[Ada] Ada2020: AI12-0027 Access values and unaliased componentJavier Miranda1-0/+37
gcc/ada/ * sem_res.adb (Resolve_Actuals): Restrict the check on matching aliased components to view conversions of array types that are not placed in an instance. In such case at runtime an object is created. * sem_util.ads (Is_Actual_In_Out_Parameter, Is_View_Conversion): New subprograms. * sem_util.adb (Is_Actual_In_Out_Parameter, Is_View_Conversion): New subprograms.
2020-07-27[Ada] Use membership tests in front-endArnaud Charlet1-468/+422
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-16[Ada] AI12-0373 Additional check on Integer_Literal functionArnaud Charlet1-18/+7
gcc/ada/ * sem_ch13.adb (Validate_Literal_Aspect): Ensure that the parameter is not aliased. Minor reformatting. * sem_util.adb (Statically_Names_Object): Update comment.
2020-07-16[Ada] Incorrect static accessibility error in return aggregateJustin Squirek1-1/+16
gcc/ada/ * einfo.adb, einfo.ads (Is_Named_Access_Type): Created for readability. * sem_ch6.adb (Check_Return_Construct_Accessibility): Add special cases for formals. * sem_util.adb (Object_Access_Level): Add handling of access attributes and named access types in the general case.
2020-07-16[Ada] Ada2020: AI12-0107 convention of By_Protected_ProcedureJavier Miranda1-0/+11
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] Cleanup code related to object overlaysPiotr Trojanek1-2/+2
gcc/ada/ * sem_util.adb (Find_Overlaid_Entity): Fix style in comment. (Note_Possible_Modification): Simplify repeated calls to Ekind.
2020-07-15[Ada] Target name is an object referencePiotr Trojanek1-0/+5
gcc/ada/ * sem_util.adb (Is_Object_Reference): Return True on N_Target_Name.
2020-07-15[Ada] Guard against access to wrong fields in Is_RenamingGhjuvan Lacambre1-2/+22
gcc/ada/ * sem_util.adb (Is_Renaming): Add ekind checks.
2020-07-15[Ada] Missing error on operator callArnaud Charlet1-5/+5
gcc/ada/ * sem_ch6.adb (Analyze_Procedure_Call): Detect use of operators in a procedure call. * sem_util.adb: Minor edit.
2020-07-15[Ada] Fix slices and qualified expressions being effectively volatilePiotr Trojanek1-2/+9
gcc/ada/ * exp_ch5.adb (Expand_Assign_Array): Use short-circuit operator (style). * sem_res.adb (Resolve_Indexed_Component): Fix style in comment. * sem_util.adb (Is_Effectively_Volatile_Object): Handle slices just like indexed components; handle qualified expressions and type conversions lie in Is_OK_Volatile_Context. (Is_OK_Volatile_Context): Handle qualified expressions just like type conversions.
2020-07-15[Ada] Cleanup condition for an effectively volatile array typePiotr Trojanek1-14/+16
gcc/ada/ * sem_prag.adb (Atomic_Components): Simplify with Ekind_In. (Complex_Representation): Fix type of E_Id, which just like when for pragma Atomic_Components will hold an N_Identifier node, not an entity. * sem_util.adb (Is_Effectively_Volatile): Refactor to avoid unnecessary computation.
2020-07-15[Ada] Extend static functionsArnaud Charlet1-21/+22
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.