aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-06-23 12:14:03 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-15 05:39:14 -0400
commit7e3f6147a7492b774194669f3f68b979fd847811 (patch)
tree33b0894badf3f560251a87e747b9ab913e01ac6d /gcc
parentcba9c0267ac33cc1e5b14c71d2fc75ca9609cf91 (diff)
downloadgcc-7e3f6147a7492b774194669f3f68b979fd847811.zip
gcc-7e3f6147a7492b774194669f3f68b979fd847811.tar.gz
gcc-7e3f6147a7492b774194669f3f68b979fd847811.tar.bz2
[Ada] Wrong use of Scope_Depth_Value
gcc/ada/ * einfo.ads, einfo.adb (Scope_Depth_Value, Set_Scope_Depth_Value): Add assertions on valid nodes and update documentation accordingly. (Write_Field22_Name): Sync with change in Scope_Depth_Value. * sem_ch8.adb (Find_Direct_Name): Fix call to Scope_Depth_Value.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/einfo.adb36
-rw-r--r--gcc/ada/einfo.ads14
-rw-r--r--gcc/ada/sem_ch8.adb2
3 files changed, 32 insertions, 20 deletions
diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb
index bf839a5..4e41a72 100644
--- a/gcc/ada/einfo.adb
+++ b/gcc/ada/einfo.adb
@@ -3311,6 +3311,13 @@ package body Einfo is
function Scope_Depth_Value (Id : E) return U is
begin
+ pragma Assert
+ (Ekind (Id) in
+ Concurrent_Kind | Entry_Kind | Generic_Unit_Kind |
+ E_Package | E_Package_Body | Subprogram_Kind |
+ E_Block | E_Subprogram_Body |
+ E_Private_Type .. E_Limited_Private_Subtype |
+ E_Void | E_Loop | E_Return_Statement);
return Uint22 (Id);
end Scope_Depth_Value;
@@ -6582,7 +6589,13 @@ package body Einfo is
procedure Set_Scope_Depth_Value (Id : E; V : U) is
begin
- pragma Assert (not Is_Record_Type (Id));
+ pragma Assert
+ (Ekind (Id) in
+ Concurrent_Kind | Entry_Kind | Generic_Unit_Kind |
+ E_Package | E_Package_Body | Subprogram_Kind |
+ E_Block | E_Subprogram_Body |
+ E_Private_Type .. E_Limited_Private_Subtype |
+ E_Void | E_Loop | E_Return_Statement);
Set_Uint22 (Id, V);
end Set_Scope_Depth_Value;
@@ -10873,21 +10886,18 @@ package body Einfo is
when Formal_Kind =>
Write_Str ("Protected_Formal");
- when E_Block
- | E_Entry
- | E_Entry_Family
- | E_Function
- | E_Generic_Function
- | E_Generic_Package
- | E_Generic_Procedure
- | E_Loop
+ when Concurrent_Kind
+ | Entry_Kind
+ | Generic_Unit_Kind
| E_Package
| E_Package_Body
- | E_Procedure
- | E_Protected_Type
- | E_Return_Statement
+ | Subprogram_Kind
+ | E_Block
| E_Subprogram_Body
- | E_Task_Type
+ | E_Private_Type .. E_Limited_Private_Subtype
+ | E_Void
+ | E_Loop
+ | E_Return_Statement
=>
Write_Str ("Scope_Depth_Value");
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 7932c92..765d0f4 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -4280,14 +4280,16 @@ package Einfo is
-- the Scope will be Standard.
-- Scope_Depth (synthesized)
--- Applies to program units, blocks, concurrent types and entries, and
--- also to record types, i.e. to any entity that can appear on the scope
--- stack. Yields the scope depth value, which for those entities other
--- than records is simply the scope depth value, for record entities, it
--- is the Scope_Depth of the record scope.
+-- Applies to program units, blocks, loops, return statements,
+-- concurrent types, private types and entries, and also to record types,
+-- i.e. to any entity that can appear on the scope stack. Yields the
+-- scope depth value, which for those entities other than records is
+-- simply the scope depth value, for record entities, it is the
+-- Scope_Depth of the record scope.
-- Scope_Depth_Value (Uint22)
--- Defined in program units, blocks, concurrent types, and entries.
+-- Defined in program units, blocks, loops, return statements,
+-- concurrent types, private types and entries.
-- Indicates the number of scopes that statically enclose the declaration
-- of the unit or type. Library units have a depth of zero. Note that
-- record types can act as scopes but do NOT have this field set (see
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 3c10a96..73f73c6 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -5752,7 +5752,7 @@ package body Sem_Ch8 is
-- outside the instance.
if From_Actual_Package (E)
- and then Scope_Depth (E2) < Scope_Depth (Inst)
+ and then Scope_Depth (Scope (E2)) < Scope_Depth (Inst)
then
goto Found;
else