diff options
Diffstat (limited to 'gcc/ada/sem_aggr.adb')
-rw-r--r-- | gcc/ada/sem_aggr.adb | 141 |
1 files changed, 69 insertions, 72 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index af29d9a3fdc..ad01bd18117 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -509,9 +509,8 @@ package body Sem_Aggr is ------------------------ function Array_Aggr_Subtype - (N : Node_Id; - Typ : Entity_Id) - return Entity_Id + (N : Node_Id; + Typ : Entity_Id) return Entity_Id is Aggr_Dimension : constant Pos := Number_Dimensions (Typ); -- Number of aggregate index dimensions @@ -618,7 +617,7 @@ package body Sem_Aggr is -- Array_Aggr_Subtype variables Itype : Entity_Id; - -- the final itype of the overall aggregate + -- The final itype of the overall aggregate Index_Constraints : constant List_Id := New_List; -- The list of index constraints of the aggregate itype @@ -626,8 +625,8 @@ package body Sem_Aggr is -- Start of processing for Array_Aggr_Subtype begin - -- Make sure that the list of index constraints is properly attached - -- to the tree, and then collect the aggregate bounds. + -- Make sure that the list of index constraints is properly attached to + -- the tree, and then collect the aggregate bounds. Set_Parent (Index_Constraints, N); Collect_Aggr_Bounds (N, 1); @@ -672,13 +671,13 @@ package body Sem_Aggr is Itype := Create_Itype (E_Array_Subtype, N); - Set_First_Rep_Item (Itype, First_Rep_Item (Typ)); - Set_Convention (Itype, Convention (Typ)); - Set_Depends_On_Private (Itype, Has_Private_Component (Typ)); - Set_Etype (Itype, Base_Type (Typ)); - Set_Has_Alignment_Clause (Itype, Has_Alignment_Clause (Typ)); - Set_Is_Aliased (Itype, Is_Aliased (Typ)); - Set_Depends_On_Private (Itype, Depends_On_Private (Typ)); + Set_First_Rep_Item (Itype, First_Rep_Item (Typ)); + Set_Convention (Itype, Convention (Typ)); + Set_Depends_On_Private (Itype, Has_Private_Component (Typ)); + Set_Etype (Itype, Base_Type (Typ)); + Set_Has_Alignment_Clause (Itype, Has_Alignment_Clause (Typ)); + Set_Is_Aliased (Itype, Is_Aliased (Typ)); + Set_Depends_On_Private (Itype, Depends_On_Private (Typ)); Copy_Suppress_Status (Index_Check, Typ, Itype); Copy_Suppress_Status (Length_Check, Typ, Itype); @@ -688,22 +687,23 @@ package body Sem_Aggr is Set_Is_Internal (Itype, True); -- A simple optimization: purely positional aggregates of static - -- components should be passed to gigi unexpanded whenever possible, - -- and regardless of the staticness of the bounds themselves. Subse- - -- quent checks in exp_aggr verify that type is not packed, etc. + -- components should be passed to gigi unexpanded whenever possible, and + -- regardless of the staticness of the bounds themselves. Subsequent + -- checks in exp_aggr verify that type is not packed, etc. Set_Size_Known_At_Compile_Time (Itype, Is_Fully_Positional and then Comes_From_Source (N) and then Size_Known_At_Compile_Time (Component_Type (Typ))); - -- We always need a freeze node for a packed array subtype, so that - -- we can build the Packed_Array_Type corresponding to the subtype. - -- If expansion is disabled, the packed array subtype is not built, - -- and we must not generate a freeze node for the type, or else it - -- will appear incomplete to gigi. + -- We always need a freeze node for a packed array subtype, so that we + -- can build the Packed_Array_Type corresponding to the subtype. If + -- expansion is disabled, the packed array subtype is not built, and we + -- must not generate a freeze node for the type, or else it will appear + -- incomplete to gigi. - if Is_Packed (Itype) and then not In_Spec_Expression + if Is_Packed (Itype) + and then not In_Spec_Expression and then Expander_Active then Freeze_Itype (Itype, N); @@ -728,11 +728,10 @@ package body Sem_Aggr is Component_Elmt : Elmt_Id; begin - -- All the components of List are matched against Component and - -- a count is maintained of possible misspellings. When at the - -- end of the analysis there are one or two (not more!) possible - -- misspellings, these misspellings will be suggested as - -- possible correction. + -- All the components of List are matched against Component and a count + -- is maintained of possible misspellings. When at the end of the + -- the analysis there are one or two (not more!) possible misspellings, + -- these misspellings will be suggested as possible correction. Component_Elmt := First_Elmt (Elements); while Nr_Of_Suggestions <= Max_Suggestions @@ -872,7 +871,7 @@ package body Sem_Aggr is Append_To (Exprs, C_Node); P := P + 1; - -- something special for wide strings ??? + -- Something special for wide strings??? end loop; New_N := Make_Aggregate (Loc, Expressions => Exprs); @@ -904,9 +903,9 @@ package body Sem_Aggr is end if; -- Check for aggregates not allowed in configurable run-time mode. - -- We allow all cases of aggregates that do not come from source, - -- since these are all assumed to be small (e.g. bounds of a string - -- literal). We also allow aggregates of types we know to be small. + -- We allow all cases of aggregates that do not come from source, since + -- these are all assumed to be small (e.g. bounds of a string literal). + -- We also allow aggregates of types we know to be small. if not Support_Aggregates_On_Target and then Comes_From_Source (N) @@ -941,10 +940,10 @@ package body Sem_Aggr is -- First a special test, for the case of a positional aggregate -- of characters which can be replaced by a string literal. - -- Do not perform this transformation if this was a string literal - -- to start with, whose components needed constraint checks, or if - -- the component type is non-static, because it will require those - -- checks and be transformed back into an aggregate. + -- Do not perform this transformation if this was a string literal to + -- start with, whose components needed constraint checks, or if the + -- component type is non-static, because it will require those checks + -- and be transformed back into an aggregate. if Number_Dimensions (Typ) = 1 and then Is_Standard_Character_Type (Component_Type (Typ)) @@ -989,10 +988,10 @@ package body Sem_Aggr is Aggr_Resolved : Boolean; Aggr_Typ : constant Entity_Id := Etype (Typ); - -- This is the unconstrained array type, which is the type - -- against which the aggregate is to be resolved. Typ itself - -- is the array type of the context which may not be the same - -- subtype as the subtype for the final aggregate. + -- This is the unconstrained array type, which is the type against + -- which the aggregate is to be resolved. Typ itself is the array + -- type of the context which may not be the same subtype as the + -- subtype for the final aggregate. begin -- In the following we determine whether an others choice is @@ -1002,11 +1001,11 @@ package body Sem_Aggr is -- choice is not allowed. -- If expansion is disabled (generic context, or semantics-only - -- mode) actual subtypes cannot be constructed, and the type of - -- an object may be its unconstrained nominal type. However, if - -- the context is an assignment, we assume that "others" is - -- allowed, because the target of the assignment will have a - -- constrained subtype when fully compiled. + -- mode) actual subtypes cannot be constructed, and the type of an + -- object may be its unconstrained nominal type. However, if the + -- context is an assignment, we assume that "others" is allowed, + -- because the target of the assignment will have a constrained + -- subtype when fully compiled. -- Note that there is no node for Explicit_Actual_Parameter. -- To test for this context we therefore have to test for node @@ -1014,7 +1013,7 @@ package body Sem_Aggr is -- formal parameter. Consequently we also need to test for -- N_Procedure_Call_Statement or N_Function_Call. - Set_Etype (N, Aggr_Typ); -- may be overridden later on + Set_Etype (N, Aggr_Typ); -- May be overridden later on if Is_Constrained (Typ) and then (Pkind = N_Assignment_Statement or else @@ -1080,10 +1079,10 @@ package body Sem_Aggr is Error_Msg_N ("illegal context for aggregate", N); end if; - -- If we can determine statically that the evaluation of the - -- aggregate raises Constraint_Error, then replace the - -- aggregate with an N_Raise_Constraint_Error node, but set the - -- Etype to the right aggregate subtype. Gigi needs this. + -- If we can determine statically that the evaluation of the aggregate + -- raises Constraint_Error, then replace the aggregate with an + -- N_Raise_Constraint_Error node, but set the Etype to the right + -- aggregate subtype. Gigi needs this. if Raises_Constraint_Error (N) then Aggr_Subtyp := Etype (N); @@ -1115,13 +1114,13 @@ package body Sem_Aggr is Index_Typ : constant Entity_Id := Etype (Index); Index_Typ_Low : constant Node_Id := Type_Low_Bound (Index_Typ); Index_Typ_High : constant Node_Id := Type_High_Bound (Index_Typ); - -- The type of the index corresponding to the array sub-aggregate - -- along with its low and upper bounds + -- The type of the index corresponding to the array sub-aggregate along + -- with its low and upper bounds. Index_Base : constant Entity_Id := Base_Type (Index_Typ); Index_Base_Low : constant Node_Id := Type_Low_Bound (Index_Base); Index_Base_High : constant Node_Id := Type_High_Bound (Index_Base); - -- ditto for the base type + -- Ditto for the base type function Add (Val : Uint; To : Node_Id) return Node_Id; -- Creates a new expression node where Val is added to expression To. @@ -1131,16 +1130,16 @@ package body Sem_Aggr is procedure Check_Bound (BH : Node_Id; AH : in out Node_Id); -- Checks that AH (the upper bound of an array aggregate) is <= BH -- (the upper bound of the index base type). If the check fails a - -- warning is emitted, the Raises_Constraint_Error Flag of N is set, + -- warning is emitted, the Raises_Constraint_Error flag of N is set, -- and AH is replaced with a duplicate of BH. procedure Check_Bounds (L, H : Node_Id; AL, AH : Node_Id); -- Checks that range AL .. AH is compatible with range L .. H. Emits a - -- warning if not and sets the Raises_Constraint_Error Flag in N. + -- warning if not and sets the Raises_Constraint_Error flag in N. procedure Check_Length (L, H : Node_Id; Len : Uint); -- Checks that range L .. H contains at least Len elements. Emits a - -- warning if not and sets the Raises_Constraint_Error Flag in N. + -- warning if not and sets the Raises_Constraint_Error flag in N. function Dynamic_Or_Null_Range (L, H : Node_Id) return Boolean; -- Returns True if range L .. H is dynamic or null @@ -1155,11 +1154,10 @@ package body Sem_Aggr is Single_Elmt : Boolean) return Boolean; -- Resolves aggregate expression Expr. Returns False if resolution -- fails. If Single_Elmt is set to False, the expression Expr may be - -- used to initialize several array aggregate elements (this can - -- happen for discrete choices such as "L .. H => Expr" or the others - -- choice). In this event we do not resolve Expr unless expansion is - -- disabled. To know why, see the DELAYED COMPONENT RESOLUTION - -- note above. + -- used to initialize several array aggregate elements (this can happen + -- for discrete choices such as "L .. H => Expr" or the others choice). + -- In this event we do not resolve Expr unless expansion is disabled. + -- To know why, see the DELAYED COMPONENT RESOLUTION note above. --------- -- Add -- @@ -1642,8 +1640,8 @@ package body Sem_Aggr is -- discrete association Prev_Nb_Discrete_Choices : Nat; - -- Used to keep track of the number of discrete choices - -- in the current association. + -- Used to keep track of the number of discrete choices in the + -- current association. begin -- STEP 2 (A): Check discrete choices validity @@ -1690,9 +1688,8 @@ package body Sem_Aggr is Check_Non_Static_Context (Choice); -- Do not range check a choice. This check is redundant - -- since this test is already performed when we check - -- that the bounds of the array aggregate are within - -- range. + -- since this test is already done when we check that the + -- bounds of the array aggregate are within range. Set_Do_Range_Check (Choice, False); end if; @@ -1754,13 +1751,13 @@ package body Sem_Aggr is end if; -- Ada 2005 (AI-287): In case of default initialized component - -- we delay the resolution to the expansion phase + -- we delay the resolution to the expansion phase. if Box_Present (Assoc) then - -- Ada 2005 (AI-287): In case of default initialization - -- of a component the expander will generate calls to - -- the corresponding initialization subprogram. + -- Ada 2005 (AI-287): In case of default initialization of a + -- component the expander will generate calls to the + -- corresponding initialization subprogram. null; @@ -1773,8 +1770,8 @@ package body Sem_Aggr is -- We differentiate here two cases because the expression may -- not be decorated. For example, the analysis and resolution - -- of the expression associated with the others choice will - -- be done later with the full aggregate. In such case we + -- of the expression associated with the others choice will be + -- done later with the full aggregate. In such case we -- duplicate the expression tree to analyze the copy and -- perform the required check. @@ -1810,7 +1807,7 @@ package body Sem_Aggr is end loop; -- If aggregate contains more than one choice then these must be - -- static. Sort them and check that they are contiguous + -- static. Sort them and check that they are contiguous. if Nb_Discrete_Choices > 1 then Sort_Case_Table (Table); |