[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
This commit is contained in:
Arnaud Charlet 2016-04-21 11:54:42 +02:00
parent 22a4f9d54d
commit f76647c2ec
5 changed files with 98 additions and 45 deletions

View File

@ -1,3 +1,13 @@
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>
* s-soflin.adb: Initialize the Stack_Limit global variable.

View File

@ -1458,6 +1458,35 @@ package body Exp_Dbug is
else
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;
end if;

View File

@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -435,6 +435,21 @@ package Exp_Dbug is
-- generating code, since the necessary information for computing the
-- 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 --
--------------------------------------------

View File

@ -81,12 +81,6 @@ package body Exp_Pakd is
-- 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
(Atyp : Entity_Id;
N : Node_Id;
@ -96,6 +90,12 @@ package body Exp_Pakd is
-- Standard.Integer representing the zero-based linear subscript value.
-- 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);
-- Given an expression of a packed array type, builds a corresponding
-- expression whose type is the implementation type used to represent
@ -266,38 +266,6 @@ package body Exp_Pakd is
return Adjusted;
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 --
------------------------------
@ -434,6 +402,38 @@ package body Exp_Pakd is
end loop;
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 --
-------------------------
@ -1882,14 +1882,13 @@ package body Exp_Pakd is
LLexpr :=
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)));
RLexpr :=
Make_Op_Multiply (Loc,
Left_Opnd => Compute_Number_Components (N, Rtyp),
Right_Opnd =>
Make_Integer_Literal (Loc, Component_Size (Rtyp)));
Left_Opnd => Compute_Number_Components (N, Rtyp),
Right_Opnd => Make_Integer_Literal (Loc, Component_Size (Rtyp)));
-- For the modular case, we transform the comparison to:

View File

@ -8646,8 +8646,8 @@ package body Sem_Ch13 is
-- function at this point.
elsif Nkind (Ritem) = N_Aspect_Specification
and then Present (Aspect_Rep_Item (Ritem))
and then Scope (Typ) /= Current_Scope
and then Present (Aspect_Rep_Item (Ritem))
and then Scope (Typ) /= Current_Scope
then
declare
Prag : constant Node_Id := Aspect_Rep_Item (Ritem);