+2017-01-13 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_aggr.adb (Resolve_Array_Aggregate): The code that verifies
+ the legality of An others clause applies as well to a choice in
+ an Iterated_component_ association.
+ (Resolve_Iterated_Component_Association): An others choice
+ is legal.
+ * exp_aggr.adb (Aggr_Assignment_OK_For_Backend): An
+ Iterated_Component_Association is not static.
+
+2017-01-13 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * exp_ch3.adb (Freeze_Type): Mark the Ghost mode as set in case
+ control is passed to the expresion handler before the new mode
+ is set.
+ * sem_ch12.adb (Analyze_Package_Instantiation,
+ Analyze_Subprogram_Instantiation): Mark the Ghost mode as set
+ in case control is passed to the expresion handler before the
+ new mode is set.
+
2017-01-13 Hristian Kirtchev <kirtchev@adacore.com>
* sem_aggr.adb, sem_ch3.adb, inline.adb, sem_util.adb, exp_ch4.adb,
-- values, and can be passed as is to the back-end without further
-- expansion.
-- An Iterated_component_Association is treated as non-static, but there
- -- are posibilities for optimization here.
+ -- are possibilities for optimization here.
function Flatten
(N : Node_Id;
end if;
end loop;
+ -- An Iterated_Component_Association involves a loop (in most cases)
+ -- and is never static.
+
+ if Nkind (Parent (Expr)) = N_Iterated_Component_Association then
+ return False;
+ end if;
+
if not Is_Discrete_Type (Ctyp) then
return False;
end if;
-- Local variables
Def_Id : constant Entity_Id := Entity (N);
- Mode : Ghost_Mode_Type;
- Result : Boolean := False;
+
+ Mode : Ghost_Mode_Type;
+ Mode_Set : Boolean := False;
+ Result : Boolean := False;
-- Start of processing for Freeze_Type
-- marked as Ghost.
Set_Ghost_Mode (Def_Id, Mode);
+ Mode_Set := True;
-- Process any remote access-to-class-wide types designating the type
-- being frozen.
Build_Invariant_Procedure_Body (Def_Id);
end if;
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
+
return Result;
exception
when RE_Not_Available =>
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
+
return False;
end Freeze_Type;
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
- Error_Msg_N ("others choice not allowed in this context", N);
Others_Present := True;
else
Analyze_And_Resolve (Choice, Index_Typ);
end if;
- Nb_Choices := Nb_Choices + 1;
Next (Choice);
end loop;
-- Create a scope in which to introduce an index, which is usually
- -- visible in the expression for the component.
+ -- visible in the expression for the component, and needed for its
+ -- analysis.
Ent := New_Internal_Entity (E_Loop, Current_Scope, Loc, 'L');
Set_Etype (Ent, Standard_Void_Type);
while Present (Assoc) loop
if Nkind (Assoc) = N_Iterated_Component_Association then
Resolve_Iterated_Component_Association (Assoc, Index_Typ);
- goto Next_Assoc;
end if;
- Choice := First (Choices (Assoc));
+ Choice := First (Choice_List (Assoc));
Delete_Choice := False;
while Present (Choice) loop
if Nkind (Choice) = N_Others_Choice then
Others_Present := True;
- if Choice /= First (Choices (Assoc))
+ if Choice /= First (Choice_List (Assoc))
or else Present (Next (Choice))
then
Error_Msg_N
end;
end loop;
- <<Next_Assoc>>
Next (Assoc);
end loop;
end if;
-- Local declarations
- Mode : Ghost_Mode_Type;
+ Mode : Ghost_Mode_Type;
+ Mode_Set : Boolean := False;
Vis_Prims_List : Elist_Id := No_Elist;
-- List of primitives made temporarily visible in the instantiation
-- Ghost.
Mark_And_Set_Ghost_Instantiation (N, Gen_Unit, Mode);
+ Mode_Set := True;
-- Verify that it is the name of a generic package
Analyze_Aspect_Specifications (N, Act_Decl_Id);
end if;
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
exception
when Instantiation_Error =>
SPARK_Mode_Pragma := Save_SMP;
Style_Check := Save_Style_Check;
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
end Analyze_Package_Instantiation;
--------------------------
-- Local variables
- Mode : Ghost_Mode_Type;
-
Save_IPSM : constant Boolean := Ignore_Pragma_SPARK_Mode;
-- Save flag Ignore_Pragma_SPARK_Mode for restore on exit
Save_SMP : constant Node_Id := SPARK_Mode_Pragma;
-- Save the SPARK_Mode-related data for restore on exit
+ Mode : Ghost_Mode_Type;
+ Mode_Set : Boolean := False;
+
Vis_Prims_List : Elist_Id := No_Elist;
-- List of primitives made temporarily visible in the instantiation
-- to match the visibility of the formal type
-- Ghost.
Mark_And_Set_Ghost_Instantiation (N, Gen_Unit, Mode);
+ Mode_Set := True;
Generate_Reference (Gen_Unit, Gen_Id);
Analyze_Aspect_Specifications (N, Act_Decl_Id);
end if;
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
exception
when Instantiation_Error =>
SPARK_Mode := Save_SM;
SPARK_Mode_Pragma := Save_SMP;
- Restore_Ghost_Mode (Mode);
+ if Mode_Set then
+ Restore_Ghost_Mode (Mode);
+ end if;
end Analyze_Subprogram_Instantiation;
-------------------------