aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Quinot <quinot@adacore.com>2008-08-22 14:10:38 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2008-08-22 14:10:38 +0200
commit7ca139d3886e36e94981d4d1d3aed06b2a8bdc56 (patch)
tree1d8d66cf08ab15a4a0af39e3a693d59967e20718 /gcc
parent3df684e2a916fa5ed6e95469ac2cafcc597fa430 (diff)
downloadgcc-7ca139d3886e36e94981d4d1d3aed06b2a8bdc56.zip
gcc-7ca139d3886e36e94981d4d1d3aed06b2a8bdc56.tar.gz
gcc-7ca139d3886e36e94981d4d1d3aed06b2a8bdc56.tar.bz2
sem_ch8.adb: Minor reformatting Minor code reorganization (introduce subprogram to factor...
2008-08-22 Thomas Quinot <quinot@adacore.com> * sem_ch8.adb: Minor reformatting Minor code reorganization (introduce subprogram to factor duplicated code). From-SVN: r139439
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch8.adb44
1 files changed, 26 insertions, 18 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 67d2164..1c7f1a1 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -7073,6 +7073,27 @@ package body Sem_Ch8 is
Unit1 : Node_Id;
Unit2 : Node_Id;
+ function Entity_Of_Unit (U : Node_Id) return Entity_Id;
+ -- Return the appropriate entity for determining which unit
+ -- has a deeper scope: the defining entity for U, unless U
+ -- is a package instance, in which case we retrieve the
+ -- entity of the instance spec.
+
+ --------------------
+ -- Entity_Of_Unit --
+ --------------------
+
+ function Entity_Of_Unit (U : Node_Id) return Entity_Id is
+ begin
+ if Nkind (U) = N_Package_Instantiation
+ and then Analyzed (U)
+ then
+ return Defining_Entity (Instance_Spec (U));
+ else
+ return Defining_Entity (U);
+ end if;
+ end Entity_Of_Unit;
+
begin
-- If both current use type clause and the use type
-- clause for the type are at the compilation unit level,
@@ -7089,23 +7110,10 @@ package body Sem_Ch8 is
-- There is a redundant use type clause in a child unit.
-- Determine which of the units is more deeply nested.
-- If a unit is a package instance, retrieve the entity
- -- and its scope from the instance spec
+ -- and its scope from the instance spec.
- if Nkind (Unit1) = N_Package_Instantiation
- and then Analyzed (Unit1)
- then
- Ent1 := Defining_Entity (Instance_Spec (Unit1));
- else
- Ent1 := Defining_Entity (Unit1);
- end if;
-
- if Nkind (Unit2) = N_Package_Instantiation
- and then Analyzed (Unit2)
- then
- Ent2 := Defining_Entity (Instance_Spec (Unit2));
- else
- Ent2 := Defining_Entity (Unit2);
- end if;
+ Ent1 := Entity_Of_Unit (Unit1);
+ Ent2 := Entity_Of_Unit (Unit2);
if Scope (Ent2) = Standard_Standard then
Error_Msg_Sloc := Sloc (Current_Use_Clause (T));
@@ -7115,8 +7123,8 @@ package body Sem_Ch8 is
Error_Msg_Sloc := Sloc (Id);
Err_No := Clause2;
- -- If both units are child units, we determine which
- -- one is the descendant by the scope distance to the
+ -- If both units are child units, we determine which one
+ -- is the descendant by the scope distance to the
-- ultimate parent unit.
else