Commit f76647c2 by Arnaud Charlet

[multiple changes]

2016-04-21  Hristian Kirtchev  <kirtchev@adacore.com>

	* exp_pakd.adb, sem_ch13.adb: Minor reformatting.

2016-04-21  Ed Schonberg  <schonberg@adacore.com>

	* exp_dbug.adb, exp_dbug.ads (Qualify_Entity_Name): Add suffixes to
	disambiguate local variables that may be hidden from inner visibility
	by nested block declarations or loop variables.

From-SVN: r235327
parent 22a4f9d5
2016-04-21 Hristian Kirtchev <kirtchev@adacore.com>
* exp_pakd.adb, sem_ch13.adb: Minor reformatting.
2016-04-21 Ed Schonberg <schonberg@adacore.com>
* exp_dbug.adb, exp_dbug.ads (Qualify_Entity_Name): Add suffixes to
disambiguate local variables that may be hidden from inner visibility
by nested block declarations or loop variables.
2016-04-21 Jerome Lambourg <lambourg@adacore.com> 2016-04-21 Jerome Lambourg <lambourg@adacore.com>
* s-soflin.adb: Initialize the Stack_Limit global variable. * s-soflin.adb: Initialize the Stack_Limit global variable.
......
...@@ -1458,6 +1458,35 @@ package body Exp_Dbug is ...@@ -1458,6 +1458,35 @@ package body Exp_Dbug is
else else
Set_Has_Qualified_Name (Ent); Set_Has_Qualified_Name (Ent);
-- If a variable is hidden by a subsequent loop variable, qualify
-- the name of that loop variable to prevent visibility issues when
-- translating to C. Note that gdb probably never handled properly
-- this accidental hiding, given that loops are not scopes at
-- runtime. We also qualify a name if it hides an outer homonym,
-- and both are declared in blocks.
if Modify_Tree_For_C and then Ekind (Ent) = E_Variable then
if Present (Hiding_Loop_Variable (Ent)) then
declare
Var : constant Entity_Id := Hiding_Loop_Variable (Ent);
begin
Set_Entity_Name (Var);
Add_Str_To_Name_Buffer ("L");
Set_Chars (Var, Name_Enter);
end;
elsif Present (Homonym (Ent))
and then Ekind (Scope (Ent)) = E_Block
and then Ekind (Scope (Homonym (Ent))) = E_Block
then
Set_Entity_Name (Ent);
Add_Str_To_Name_Buffer ("B");
Set_Chars (Ent, Name_Enter);
end if;
end if;
return; return;
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1996-2015, Free Software Foundation, Inc. -- -- Copyright (C) 1996-2016, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -435,6 +435,21 @@ package Exp_Dbug is ...@@ -435,6 +435,21 @@ package Exp_Dbug is
-- generating code, since the necessary information for computing the -- generating code, since the necessary information for computing the
-- proper external name is not available in this case. -- proper external name is not available in this case.
-------------------------------------
-- Encoding for translation into C --
-------------------------------------
-- In Modify_Tree_For_C mode we must add encodings to dismabiguate cases
-- where Ada block structure cannot be directly translated. These cases
-- are as follows:
-- a) A loop variable may hide a homonym in an enclosing block
-- b) A block-local variable may hide a homonym in an enclosing block
-- In C these constructs are not scopes and we must distinguish the names
-- explicitly. In the first case we create a qualified name with the suffix
-- 'L', in the second case with a suffix 'B'.
-------------------------------------------- --------------------------------------------
-- Subprograms for Handling Qualification -- -- Subprograms for Handling Qualification --
-------------------------------------------- --------------------------------------------
......
...@@ -81,12 +81,6 @@ package body Exp_Pakd is ...@@ -81,12 +81,6 @@ package body Exp_Pakd is
-- Local Subprograms -- -- Local Subprograms --
----------------------- -----------------------
function Compute_Number_Components
(N : Node_Id;
Typ : Entity_Id) return Node_Id;
-- Build an expression that multiplies the length of the dimensions of the
-- array, used to control array equality checks.
procedure Compute_Linear_Subscript procedure Compute_Linear_Subscript
(Atyp : Entity_Id; (Atyp : Entity_Id;
N : Node_Id; N : Node_Id;
...@@ -96,6 +90,12 @@ package body Exp_Pakd is ...@@ -96,6 +90,12 @@ package body Exp_Pakd is
-- Standard.Integer representing the zero-based linear subscript value. -- Standard.Integer representing the zero-based linear subscript value.
-- This expression includes any required range checks. -- This expression includes any required range checks.
function Compute_Number_Components
(N : Node_Id;
Typ : Entity_Id) return Node_Id;
-- Build an expression that multiplies the length of the dimensions of the
-- array, used to control array equality checks.
procedure Convert_To_PAT_Type (Aexp : Node_Id); procedure Convert_To_PAT_Type (Aexp : Node_Id);
-- Given an expression of a packed array type, builds a corresponding -- Given an expression of a packed array type, builds a corresponding
-- expression whose type is the implementation type used to represent -- expression whose type is the implementation type used to represent
...@@ -266,38 +266,6 @@ package body Exp_Pakd is ...@@ -266,38 +266,6 @@ package body Exp_Pakd is
return Adjusted; return Adjusted;
end Revert_Storage_Order; end Revert_Storage_Order;
-------------------------------
-- Compute_Number_Components --
-------------------------------
function Compute_Number_Components
(N : Node_Id;
Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (N);
Len_Expr : Node_Id;
begin
Len_Expr :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix => New_Occurrence_Of (Typ, Loc),
Expressions => New_List (Make_Integer_Literal (Loc, 1)));
for J in 2 .. Number_Dimensions (Typ) loop
Len_Expr :=
Make_Op_Multiply (Loc,
Left_Opnd => Len_Expr,
Right_Opnd =>
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix => New_Occurrence_Of (Typ, Loc),
Expressions => New_List (Make_Integer_Literal (Loc, J))));
end loop;
return Len_Expr;
end Compute_Number_Components;
------------------------------ ------------------------------
-- Compute_Linear_Subscript -- -- Compute_Linear_Subscript --
------------------------------ ------------------------------
...@@ -434,6 +402,38 @@ package body Exp_Pakd is ...@@ -434,6 +402,38 @@ package body Exp_Pakd is
end loop; end loop;
end Compute_Linear_Subscript; end Compute_Linear_Subscript;
-------------------------------
-- Compute_Number_Components --
-------------------------------
function Compute_Number_Components
(N : Node_Id;
Typ : Entity_Id) return Node_Id
is
Loc : constant Source_Ptr := Sloc (N);
Len_Expr : Node_Id;
begin
Len_Expr :=
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix => New_Occurrence_Of (Typ, Loc),
Expressions => New_List (Make_Integer_Literal (Loc, 1)));
for J in 2 .. Number_Dimensions (Typ) loop
Len_Expr :=
Make_Op_Multiply (Loc,
Left_Opnd => Len_Expr,
Right_Opnd =>
Make_Attribute_Reference (Loc,
Attribute_Name => Name_Length,
Prefix => New_Occurrence_Of (Typ, Loc),
Expressions => New_List (Make_Integer_Literal (Loc, J))));
end loop;
return Len_Expr;
end Compute_Number_Components;
------------------------- -------------------------
-- Convert_To_PAT_Type -- -- Convert_To_PAT_Type --
------------------------- -------------------------
...@@ -1882,14 +1882,13 @@ package body Exp_Pakd is ...@@ -1882,14 +1882,13 @@ package body Exp_Pakd is
LLexpr := LLexpr :=
Make_Op_Multiply (Loc, Make_Op_Multiply (Loc,
Left_Opnd => Compute_Number_Components (N, Ltyp), Left_Opnd => Compute_Number_Components (N, Ltyp),
Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp))); Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Ltyp)));
RLexpr := RLexpr :=
Make_Op_Multiply (Loc, Make_Op_Multiply (Loc,
Left_Opnd => Compute_Number_Components (N, Rtyp), Left_Opnd => Compute_Number_Components (N, Rtyp),
Right_Opnd => Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp)));
Make_Integer_Literal (Loc, Component_Size (Rtyp)));
-- For the modular case, we transform the comparison to: -- For the modular case, we transform the comparison to:
......
...@@ -8646,8 +8646,8 @@ package body Sem_Ch13 is ...@@ -8646,8 +8646,8 @@ package body Sem_Ch13 is
-- function at this point. -- function at this point.
elsif Nkind (Ritem) = N_Aspect_Specification elsif Nkind (Ritem) = N_Aspect_Specification
and then Present (Aspect_Rep_Item (Ritem)) and then Present (Aspect_Rep_Item (Ritem))
and then Scope (Typ) /= Current_Scope and then Scope (Typ) /= Current_Scope
then then
declare declare
Prag : constant Node_Id := Aspect_Rep_Item (Ritem); Prag : constant Node_Id := Aspect_Rep_Item (Ritem);
......
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