aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2020-06-22 15:23:45 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-15 05:39:08 -0400
commit46a3809b1579cb86574c6ba8e2858a8f369f8786 (patch)
treefb25eeb56f4c5b11a0f9ad06e20da8e1ea6d9b57 /gcc
parentacc1708cf088b47919785e6a50fa7a636b3fb82b (diff)
downloadgcc-46a3809b1579cb86574c6ba8e2858a8f369f8786.zip
gcc-46a3809b1579cb86574c6ba8e2858a8f369f8786.tar.gz
gcc-46a3809b1579cb86574c6ba8e2858a8f369f8786.tar.bz2
[Ada] Ada2020: AI12-0180 Using subprograms and entries in invariants
gcc/ada/ * sem_ch13.adb (Visible_Component): Enable this code for task and protected types, as well as record and private types. * sem_ch13.ads (Replace_Type_References_Generic): Update comment. Move the efficiency comment into the body, because it's about the implementation.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch13.adb24
-rw-r--r--gcc/ada/sem_ch13.ads5
2 files changed, 19 insertions, 10 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 60660bc..28fd1ed 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -14498,11 +14498,9 @@ package body Sem_Ch13 is
function Visible_Component (Comp : Name_Id) return Entity_Id;
-- Given an identifier in the expression, check whether there is a
- -- discriminant or component of the type that is directy visible, and
- -- rewrite it as the corresponding selected component of the formal of
- -- the subprogram. The entity is located by a sequential search, which
- -- seems acceptable given the typical size of component lists and check
- -- expressions. Possible optimization ???
+ -- discriminant, component, protected procedure, or entry of the type
+ -- that is directy visible, and rewrite it as the corresponding selected
+ -- component of the formal of the subprogram.
----------------------
-- Replace_Type_Ref --
@@ -14677,14 +14675,20 @@ package body Sem_Ch13 is
function Visible_Component (Comp : Name_Id) return Entity_Id is
E : Entity_Id;
-
begin
- -- Types with nameable components are records and discriminated
- -- private types.
+ -- Types with nameable components are record, task, and protected
+ -- types, and discriminated private types.
- if Ekind (T) = E_Record_Type
+ if Ekind (T) in E_Record_Type
+ | E_Task_Type
+ | E_Protected_Type
or else (Is_Private_Type (T) and then Has_Discriminants (T))
then
+ -- This is a sequential search, which seems acceptable
+ -- efficiency-wise, given the typical size of component
+ -- lists, protected operation lists, task item lists, and
+ -- check expressions.
+
E := First_Entity (T);
while Present (E) loop
if Comes_From_Source (E) and then Chars (E) = Comp then
@@ -14695,7 +14699,7 @@ package body Sem_Ch13 is
end loop;
end if;
- -- Nothing by that name, or the type has no components
+ -- Nothing by that name
return Empty;
end Visible_Component;
diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads
index 3d24c04..525d3e4 100644
--- a/gcc/ada/sem_ch13.ads
+++ b/gcc/ada/sem_ch13.ads
@@ -164,6 +164,11 @@ package Sem_Ch13 is
-- parameter does the actual replacement of node N, which is either a
-- simple direct reference to T, or a selected component that represents
-- an appropriately qualified occurrence of T.
+ --
+ -- This also replaces each reference to a component, entry, or protected
+ -- procedure with a selected component whose prefix is the parameter.
+ -- For example, Component_Name becomes Parameter.Component_Name, where
+ -- Parameter is the parameter, which is of type T.
function Rep_Item_Too_Late
(T : Entity_Id;