Commit 4f94fa11 by Arnaud Charlet

[multiple changes]

2017-01-19  Javier Miranda  <miranda@adacore.com>

	* exp_ch6.adb (Expand_Call): Remove side effects on
	actuals that are allocators with qualified expression since the
	initialization of the object is performed by means of individual
	statements (and hence it must be done before the call).

2017-01-19  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Analyze_Declarations): Minor reformatting.
	(Build_Derived_Enumeration_Type): If the derived type inherits a
	dynamic predicate from its parent, the bounds of the type must
	freeze because an explicit constraint is constructed for the
	type and the corresponding range is elaborated now.

2017-01-19  Arnaud Charlet  <charlet@adacore.com>

	* sem_attr.ads: minor fix of inconsistent casing in comment
	* lib-writ.ads: minor align comments in columns
	* sem_ch3.adb: Minor reformatting.
	* spark_xrefs.ads: minor fix typo in SPARK-related comment
	* table.ads: minor style fix in comment
	* lib-xref-spark_specific.adb
	(Add_SPARK_Xrefs): simplify processing of SPARK cross-references.
	* sem_ch12.adb: minor whitespace fix
	* freeze.adb: Add comment.
	* sem_util.adb (Unique_Name): for instances of
	generic subprograms ignore the name of the wrapper package.

2017-01-19  Javier Miranda  <miranda@adacore.com>

	* exp_aggr.adb (Resolve_Record_Aggregate):
	Factorize code needed for aggregates of limited and unlimited
	types in a new routine.
	(Pass_Aggregate_To_Back_End): New subprogram.

2017-01-19  Yannick Moy  <moy@adacore.com>

	* sinfo.adb (Pragma_Name): Only access up to Last_Pair of Pragma_Map.

From-SVN: r244622
parent 4fcf700c
2017-01-19 Javier Miranda <miranda@adacore.com>
* exp_ch6.adb (Expand_Call): Remove side effects on
actuals that are allocators with qualified expression since the
initialization of the object is performed by means of individual
statements (and hence it must be done before the call).
2017-01-19 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Declarations): Minor reformatting.
(Build_Derived_Enumeration_Type): If the derived type inherits a
dynamic predicate from its parent, the bounds of the type must
freeze because an explicit constraint is constructed for the
type and the corresponding range is elaborated now.
2017-01-19 Arnaud Charlet <charlet@adacore.com>
* sem_attr.ads: minor fix of inconsistent casing in comment
* lib-writ.ads: minor align comments in columns
* sem_ch3.adb: Minor reformatting.
* spark_xrefs.ads: minor fix typo in SPARK-related comment
* table.ads: minor style fix in comment
* lib-xref-spark_specific.adb
(Add_SPARK_Xrefs): simplify processing of SPARK cross-references.
* sem_ch12.adb: minor whitespace fix
* freeze.adb: Add comment.
* sem_util.adb (Unique_Name): for instances of
generic subprograms ignore the name of the wrapper package.
2017-01-19 Javier Miranda <miranda@adacore.com>
* exp_aggr.adb (Resolve_Record_Aggregate):
Factorize code needed for aggregates of limited and unlimited
types in a new routine.
(Pass_Aggregate_To_Back_End): New subprogram.
2017-01-19 Yannick Moy <moy@adacore.com>
* sinfo.adb (Pragma_Name): Only access up to Last_Pair of Pragma_Map.
2017-01-19 Ed Schonberg <schonberg@adacore.com> 2017-01-19 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.ads, sem_ch4.adb (Try_Object_Operation): Make subprogram * sem_ch4.ads, sem_ch4.adb (Try_Object_Operation): Make subprogram
......
...@@ -3315,6 +3315,17 @@ package body Exp_Ch6 is ...@@ -3315,6 +3315,17 @@ package body Exp_Ch6 is
Add_View_Conversion_Invariants (Formal, Actual); Add_View_Conversion_Invariants (Formal, Actual);
end if; end if;
-- Generating C the initialization of an allocator is performed by
-- means of individual statements, and hence it must be done before
-- the call.
if Modify_Tree_For_C
and then Nkind (Actual) = N_Allocator
and then Nkind (Expression (Actual)) = N_Qualified_Expression
then
Remove_Side_Effects (Actual);
end if;
-- This label is required when skipping extra actual generation for -- This label is required when skipping extra actual generation for
-- Unchecked_Union parameters. -- Unchecked_Union parameters.
......
...@@ -5305,6 +5305,9 @@ package body Freeze is ...@@ -5305,6 +5305,9 @@ package body Freeze is
-- trigger the analysis of aspect expressions, so in this case we -- trigger the analysis of aspect expressions, so in this case we
-- want to continue the freezing process. -- want to continue the freezing process.
-- Is_Generic_Unit (Scope (E)) is dubious here, do we want instead
-- In_Generic_Scope (E)???
if Present (Scope (E)) if Present (Scope (E))
and then Is_Generic_Unit (Scope (E)) and then Is_Generic_Unit (Scope (E))
and then and then
......
...@@ -381,7 +381,7 @@ package body SPARK_Specific is ...@@ -381,7 +381,7 @@ package body SPARK_Specific is
Rnums : array (0 .. Nrefs + Nrefs_Add) of Nat; Rnums : array (0 .. Nrefs + Nrefs_Add) of Nat;
-- This array contains numbers of references in the Xrefs table. This -- This array contains numbers of references in the Xrefs table. This
-- list is sorted in output order. The extra 0'th entry is convenient -- list is sorted in output order. The extra 0'th entry is convenient
-- for the call to sort. When we sort the table, we move the entries in -- for the call to sort. When we sort the table, we move the indices in
-- Rnums around, but we do not move the original table entries. -- Rnums around, but we do not move the original table entries.
--------------------- ---------------------
...@@ -683,7 +683,7 @@ package body SPARK_Specific is ...@@ -683,7 +683,7 @@ package body SPARK_Specific is
Col : Nat; Col : Nat;
From_Index : Xref_Index; From_Index : Xref_Index;
Line : Nat; Line : Nat;
Loc : Source_Ptr; Prev_Loc : Source_Ptr;
Prev_Typ : Character; Prev_Typ : Character;
Ref_Count : Nat; Ref_Count : Nat;
Ref_Id : Entity_Id; Ref_Id : Entity_Id;
...@@ -701,17 +701,9 @@ package body SPARK_Specific is ...@@ -701,17 +701,9 @@ package body SPARK_Specific is
end; end;
end loop; end loop;
-- Set up the pointer vector for the sort
for Index in 1 .. Nrefs loop
Rnums (Index) := Index;
end loop;
for Index in Drefs.First .. Drefs.Last loop for Index in Drefs.First .. Drefs.Last loop
Xrefs.Append (Drefs.Table (Index)); Xrefs.Append (Drefs.Table (Index));
Nrefs := Nrefs + 1; Nrefs := Nrefs + 1;
Rnums (Nrefs) := Xrefs.Last;
end loop; end loop;
-- Capture the definition Sloc values. As in the case of normal cross -- Capture the definition Sloc values. As in the case of normal cross
...@@ -730,7 +722,7 @@ package body SPARK_Specific is ...@@ -730,7 +722,7 @@ package body SPARK_Specific is
for Index in 1 .. Ref_Count loop for Index in 1 .. Ref_Count loop
declare declare
Ref : Xref_Key renames Xrefs.Table (Rnums (Index)).Key; Ref : Xref_Key renames Xrefs.Table (Index).Key;
begin begin
if SPARK_Entities (Ekind (Ref.Ent)) if SPARK_Entities (Ekind (Ref.Ent))
...@@ -745,7 +737,7 @@ package body SPARK_Specific is ...@@ -745,7 +737,7 @@ package body SPARK_Specific is
and then Get_Scope_Num (Ref.Ref_Scope) /= No_Scope and then Get_Scope_Num (Ref.Ref_Scope) /= No_Scope
then then
Nrefs := Nrefs + 1; Nrefs := Nrefs + 1;
Rnums (Nrefs) := Rnums (Index); Rnums (Nrefs) := Index;
end if; end if;
end; end;
end loop; end loop;
...@@ -778,7 +770,7 @@ package body SPARK_Specific is ...@@ -778,7 +770,7 @@ package body SPARK_Specific is
Ref_Count := Nrefs; Ref_Count := Nrefs;
Nrefs := 0; Nrefs := 0;
Loc := No_Location; Prev_Loc := No_Location;
Prev_Typ := 'm'; Prev_Typ := 'm';
for Index in 1 .. Ref_Count loop for Index in 1 .. Ref_Count loop
...@@ -786,10 +778,10 @@ package body SPARK_Specific is ...@@ -786,10 +778,10 @@ package body SPARK_Specific is
Ref : Xref_Key renames Xrefs.Table (Rnums (Index)).Key; Ref : Xref_Key renames Xrefs.Table (Rnums (Index)).Key;
begin begin
if Ref.Loc /= Loc if Ref.Loc /= Prev_Loc
or else (Prev_Typ = 'm' and then Ref.Typ = 'r') or else (Prev_Typ = 'm' and then Ref.Typ = 'r')
then then
Loc := Ref.Loc; Prev_Loc := Ref.Loc;
Prev_Typ := Ref.Typ; Prev_Typ := Ref.Typ;
Nrefs := Nrefs + 1; Nrefs := Nrefs + 1;
Rnums (Nrefs) := Rnums (Index); Rnums (Nrefs) := Rnums (Index);
......
...@@ -402,7 +402,7 @@ package Sem_Attr is ...@@ -402,7 +402,7 @@ package Sem_Attr is
-- fixed-point types and discrete types. For fixed-point types and -- fixed-point types and discrete types. For fixed-point types and
-- discrete types, this attribute gives the size used for default -- discrete types, this attribute gives the size used for default
-- allocation of objects and components of the size. See section in -- allocation of objects and components of the size. See section in
-- Einfo ("Handling of type'Size values") for further details. -- Einfo ("Handling of Type'Size values") for further details.
------------------------- -------------------------
-- Passed_By_Reference -- -- Passed_By_Reference --
......
...@@ -6372,8 +6372,7 @@ package body Sem_Ch12 is ...@@ -6372,8 +6372,7 @@ package body Sem_Ch12 is
Set_Is_Generic_Actual_Type (E, True); Set_Is_Generic_Actual_Type (E, True);
Set_Is_Hidden (E, False); Set_Is_Hidden (E, False);
Set_Is_Potentially_Use_Visible (E, Set_Is_Potentially_Use_Visible (E, In_Use (Instance));
In_Use (Instance));
-- We constructed the generic actual type as a subtype of the -- We constructed the generic actual type as a subtype of the
-- supplied type. This means that it normally would not inherit -- supplied type. This means that it normally would not inherit
......
...@@ -2466,6 +2466,8 @@ package body Sem_Ch3 is ...@@ -2466,6 +2466,8 @@ package body Sem_Ch3 is
Freeze_All (First_Entity (Current_Scope), Decl); Freeze_All (First_Entity (Current_Scope), Decl);
Freeze_From := Last_Entity (Current_Scope); Freeze_From := Last_Entity (Current_Scope);
-- Current scope is a package specification
elsif Scope (Current_Scope) /= Standard_Standard elsif Scope (Current_Scope) /= Standard_Standard
and then not Is_Child_Unit (Current_Scope) and then not Is_Child_Unit (Current_Scope)
and then No (Generic_Parent (Parent (L))) and then No (Generic_Parent (Parent (L)))
...@@ -2485,6 +2487,8 @@ package body Sem_Ch3 is ...@@ -2485,6 +2487,8 @@ package body Sem_Ch3 is
then then
Adjust_Decl; Adjust_Decl;
-- End of a package declaration
-- In compilation mode the expansion of freeze node takes care -- In compilation mode the expansion of freeze node takes care
-- of resolving expressions of all aspects in the list. In ASIS -- of resolving expressions of all aspects in the list. In ASIS
-- mode this must be done explicitly. -- mode this must be done explicitly.
...@@ -2495,6 +2499,9 @@ package body Sem_Ch3 is ...@@ -2495,6 +2499,9 @@ package body Sem_Ch3 is
Resolve_Aspects; Resolve_Aspects;
end if; end if;
-- This is a freeze point because it is the end of a
-- compilation unit.
Freeze_All (First_Entity (Current_Scope), Decl); Freeze_All (First_Entity (Current_Scope), Decl);
Freeze_From := Last_Entity (Current_Scope); Freeze_From := Last_Entity (Current_Scope);
...@@ -2561,6 +2568,12 @@ package body Sem_Ch3 is ...@@ -2561,6 +2568,12 @@ package body Sem_Ch3 is
end if; end if;
Adjust_Decl; Adjust_Decl;
-- The generated body of an expression function does not freeze,
-- unless it is a completion, in which case only the expression
-- itself freezes. THis is handled when the body itself is
-- analyzed (see Freeze_Expr_Types, sem_ch6.adb).
Freeze_All (Freeze_From, Decl); Freeze_All (Freeze_From, Decl);
Freeze_From := Last_Entity (Current_Scope); Freeze_From := Last_Entity (Current_Scope);
end if; end if;
...@@ -6740,8 +6753,12 @@ package body Sem_Ch3 is ...@@ -6740,8 +6753,12 @@ package body Sem_Ch3 is
-- If we constructed a default range for the case where no range -- If we constructed a default range for the case where no range
-- was given, then the expressions in the range must not freeze -- was given, then the expressions in the range must not freeze
-- since they do not correspond to expressions in the source. -- since they do not correspond to expressions in the source.
-- However, if the type inherits predicates the expressions will
-- be elaborated earlier and must freeze.
if Nkind (Indic) /= N_Subtype_Indication then if Nkind (Indic) /= N_Subtype_Indication
and then not Has_Predicates (Derived_Type)
then
Set_Must_Not_Freeze (Lo); Set_Must_Not_Freeze (Lo);
Set_Must_Not_Freeze (Hi); Set_Must_Not_Freeze (Hi);
Set_Must_Not_Freeze (Rang_Expr); Set_Must_Not_Freeze (Rang_Expr);
......
...@@ -20971,48 +20971,78 @@ package body Sem_Util is ...@@ -20971,48 +20971,78 @@ package body Sem_Util is
function Unique_Name (E : Entity_Id) return String is function Unique_Name (E : Entity_Id) return String is
-- Names of E_Subprogram_Body or E_Package_Body entities are not -- Names in E_Subprogram_Body or E_Package_Body entities are not
-- reliable, as they may not include the overloading suffix. Instead, -- reliable, as they may not include the overloading suffix. Instead,
-- when looking for the name of E or one of its enclosing scope, we get -- when looking for the name of E or one of its enclosing scope, we get
-- the name of the corresponding Unique_Entity. -- the name of the corresponding Unique_Entity.
function Get_Scoped_Name (E : Entity_Id) return String; U : constant Entity_Id := Unique_Entity (E);
-- Return the name of E prefixed by all the names of the scopes to which
-- E belongs, except for Standard.
--------------------- function This_Name return String;
-- Get_Scoped_Name --
--------------------- ---------------
-- This_Name --
---------------
function Get_Scoped_Name (E : Entity_Id) return String is function This_Name return String is
Name : constant String := Get_Name_String (Chars (E));
begin begin
if Has_Fully_Qualified_Name (E) return Get_Name_String (Chars (U));
or else Scope (E) = Standard_Standard end This_Name;
then
return Name;
else
return Get_Scoped_Name (Unique_Entity (Scope (E))) & "__" & Name;
end if;
end Get_Scoped_Name;
-- Start of processing for Unique_Name -- Start of processing for Unique_Name
begin begin
if E = Standard_Standard then if E = Standard_Standard
return Get_Name_String (Name_Standard); or else Has_Fully_Qualified_Name (E)
elsif Scope (E) = Standard_Standard
and then not (Ekind (E) = E_Package or else Is_Subprogram (E))
then then
return Get_Name_String (Name_Standard) & "__" & return This_Name;
Get_Name_String (Chars (E));
elsif Ekind (E) = E_Enumeration_Literal then elsif Ekind (E) = E_Enumeration_Literal then
return Unique_Name (Etype (E)) & "__" & Get_Name_String (Chars (E)); return Unique_Name (Etype (E)) & "__" & This_Name;
else
declare
S : constant Entity_Id := Scope (U);
pragma Assert (Present (S));
begin
-- Prefix names of predefined types with standard__, but leave
-- names of user-defined packages and subprograms without prefix
-- (even if technically they are nested in the Standard package).
if S = Standard_Standard then
if Ekind (U) = E_Package or else Is_Subprogram (U) then
return This_Name;
else else
return Get_Scoped_Name (Unique_Entity (E)); return Unique_Name (S) & "__" & This_Name;
end if;
-- For intances of generic subprograms use the name of the related
-- instace and skip the scope of its wrapper package.
elsif Is_Wrapper_Package (S) then
pragma Assert (Scope (S) = Scope (Related_Instance (S)));
-- Wrapper package and the instantiation are in the same scope
declare
Enclosing_Name : constant String :=
Unique_Name (Scope (S)) & "__" &
Get_Name_String (Chars (Related_Instance (S)));
begin
if Is_Subprogram (U)
and then not Is_Generic_Actual_Subprogram (U)
then
return Enclosing_Name;
else
return Enclosing_Name & "__" & This_Name;
end if;
end;
else
return Unique_Name (S) & "__" & This_Name;
end if;
end;
end if; end if;
end Unique_Name; end Unique_Name;
......
...@@ -6895,7 +6895,7 @@ package body Sinfo is ...@@ -6895,7 +6895,7 @@ package body Sinfo is
function Pragma_Name (N : Node_Id) return Name_Id is function Pragma_Name (N : Node_Id) return Name_Id is
Result : constant Name_Id := Pragma_Name_Unmapped (N); Result : constant Name_Id := Pragma_Name_Unmapped (N);
begin begin
for J in Pragma_Map'Range loop for J in Pragma_Map'First .. Last_Pair loop
if Result = Pragma_Map (J).Key then if Result = Pragma_Map (J).Key then
return Pragma_Map (J).Value; return Pragma_Map (J).Value;
end if; end if;
......
...@@ -137,7 +137,7 @@ package SPARK_Xrefs is ...@@ -137,7 +137,7 @@ package SPARK_Xrefs is
-- dependency-number and filename identify a file in FD lines -- dependency-number and filename identify a file in FD lines
-- entity-number and entity identify a scope in FS lines -- entity-number and entity identify a scope in FS lines
-- for the file previously identified file. -- for the previously identified file.
-- (filename and entity are just a textual representations of -- (filename and entity are just a textual representations of
-- dependency-number and entity-number) -- dependency-number and entity-number)
......
...@@ -221,8 +221,8 @@ package Table is ...@@ -221,8 +221,8 @@ package Table is
-- Writes out contents of table using Tree_IO -- Writes out contents of table using Tree_IO
procedure Tree_Read; procedure Tree_Read;
-- Initializes table by reading contents previously written -- Initializes table by reading contents previously written with the
-- with the Tree_Write call (also using Tree_IO) -- Tree_Write call (also using Tree_IO).
private private
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment