aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/fe.h
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2024-03-18 21:16:58 +0000
committerMarc Poulhiès <poulhies@adacore.com>2024-05-20 09:47:04 +0200
commit888a12b48a3ef50d467c04ccbe4cc9c937a8450e (patch)
tree2849dbea42043e28a2aa866be0fb09fcedfb3c77 /gcc/ada/fe.h
parent37f4a6f2ac22b633191d02d90054b601a73c80fa (diff)
downloadgcc-888a12b48a3ef50d467c04ccbe4cc9c937a8450e.zip
gcc-888a12b48a3ef50d467c04ccbe4cc9c937a8450e.tar.gz
gcc-888a12b48a3ef50d467c04ccbe4cc9c937a8450e.tar.bz2
ada: Resolve ACATS compilation and execution issues with container aggregates
This change set addresses various compilation and execution problems encountered in the draft ACATS tests for container aggregates: C435001 (container aggregates with Assign_Indexed) C435002 (container aggregates with Add_Unnamed) C435003 (container aggregates with Add_Named) C435004 (container aggregates with Assign_Indexed and Add_Unnamed) gcc/ada/ * exp_aggr.adb (Expand_Container_Aggregate): Add top-level variables Choice_{Lo|Hi} and Int_Choice_{Lo|Hi} used for determining the low and high bounds of component association choices. Replace code for determining whether we have an indexed aggregate with call to new function Sem_Aggr.Is_Indexed_Aggregate. Remove test of whether Empty_Subp is a function, since it must be a function. Move Default and Count_Type to be locals of a new block enclosing the code that creates the object to hold the aggregate length, and set them according to the default and type of the Empty function's parameter when present (and to Empty and Standard_Natural otherwise). Use Siz_Exp for the aggregate length when set, and use Empty's default length when available, and use zero for the length otherwise. In generating the call to the New_Indexed function, use the determined lower and upper bounds if determined earlier by Aggregate_Size, and otherwise compute those from the index type's lower bound and the determined aggregate length. In the case where a call to Empty is generated and the function has a formal parameter, pass the value saved in Siz_Decl (otherwise the parameter list is empty). Remove code specific to making a parameterless call to the Empty function. Extend the code for handling positional container aggregates to account for types that define Assign_Indexed, rather than just Add_Unnamed, and in the case of indexed aggregates, create a temporary object to hold values of the aggregate's key index, and initialize and increment that temporary for each call generated to the Assign_Indexed procedure. For named container aggregates that have key choices given by ranges, call Expand_Range_Component to generate a loop that will call the appropriate insertion procedure for each value of the range. For indexed aggregates with a Component_Associations list, set and use the Assign_Indexed procedure for each component association, whether or not there's an iterator specification. (Add_Range_Size): Add code to determine the low and high bounds of the range and capture those in up-level variables when their value is less than or greater than (respectively) the current minimum and maximum bounds values. (Aggregate_Size): Separately handle the case where a single choice is of a discrete type, and call Add_Range_Size to take its value into consideration for determination of min and max bounds of the aggregate. Add comments in a couple of places. (Build_Siz_Exp): Remove the last sentence and "???" from the comment that talks about accumulating nonstatic sizes, since that sentence seems to be obsolete. Record the low and high bound values in Choice_Lo and Choice_Hi in the case of a nonstatic range. (Expand_Iterated_Component): Set the Defining_Identifier of the iterator specification to the Loop_Id in the N_Iterated_Component_Association case. (Expand_Range_Component): Procedure unnested from the block handling indexed aggregates in Expand_Container_Aggregate, and moved to top level of that procedure so it can also be called for Add_Named cases. A formal parameter Insert_Op is added, and existing calls to this procedure are changed to pass the appropriate insertion procedure's Entity. * sem_aggr.ads: Add with_clause for Sinfo.Nodes. (Is_Indexed_Aggregate): New function for use by Resolve_Container_Aggregate and Expand_Container_Aggregate. * sem_aggr.adb: Add with_clause for Sem_Ch5. Move with_clause for Sinfo.Nodes to sem_aggr.ads. (Is_Indexed_Aggregate): New function to determine whether a container aggregate is a container aggregate (replacing local variable of the same name in Resolve_Container_Aggregate). (Resolve_Iterated_Association): Remove part of comment saying that a Key_Expression is always present. Set Parent field of the copy of a component association with a loop parameter specification. On the setting of Loop_Param_Id, account for a Loop_Parameter_Specification being changed into an Iterator_Specification as a result of being analyzed. Only call Preanalyze_And_Resolve on Key_Expr when a key expression is actually present. Remove loop for handling choices for the case of an N_Component_Association with a Defining_Identifier (there shouldn't be more than one choice in this case, and add an assertion to ensure that). Also add code here to handle the case where the choice is a function call, creating an iterator_specification analyzing it, and call Resolve_Iterated_Association recursively to process it. Add error check to enforce RM22 4.3.5(27), which requires that the type of the loop parameter must be the same as the key type when there is no key expression and the aggregate is an indexed aggregate or has an Add_Named op. (Resolve_Container_Aggregate): In the Add_Unnamed case, call Resolve_Iterated_Association for both N_Iterated_Element_Association and N_Component_Association (rather than just the latter). Remove error check for nonstatic choices in component associations in Add_Named cases (multiple named nonstatic associations are fine except in indexed aggregates). Remove local variable Is_Indexed_Aggregate, replaced with new library-level function of the same name, and add test of Is_Indexed_Aggregate in the case where the aggregate type has an Assign_Indexed operation, as a guard for doing error checks for indexed aggregates. For indexed aggregate resolution, do not call Analyze_And_Resolve on the expression of an N_Component_Association in the "box association" case. Move error checks for indexed aggregates with iterated associations that flag cases where an association is a loop_parameter_specification with an iterator filter or a key expression (violation of RM22 4.3.5(28/5)), from the loop that checks for contiguous and nonoverlapping choices and into the preceding association loop after the call to Resolve_Iterated_Association. The RM reference is added to the error-message strings.
Diffstat (limited to 'gcc/ada/fe.h')
0 files changed, 0 insertions, 0 deletions