aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-01-06 12:47:28 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-04 05:17:33 -0400
commit7f9f8889fedbe3cbba3cad870508bfc0336b3940 (patch)
treec77194f8fdab01bdb733208e6c9cc4e5e9d6a86b
parent7367cd5949ec066811979dbb60b51cbcc6c123b3 (diff)
downloadgcc-7f9f8889fedbe3cbba3cad870508bfc0336b3940.zip
gcc-7f9f8889fedbe3cbba3cad870508bfc0336b3940.tar.gz
gcc-7f9f8889fedbe3cbba3cad870508bfc0336b3940.tar.bz2
[Ada] Fix handling of access-to-variable objects in Global and Depends
gcc/ada/ * sem_prag.ads (Collect_Subprogram_Inputs_Outputs): Update comment; this routine is no longer used by GNATprove. * sem_prag.adb (Find_Role): The IN parameter is on output only when it belongs to non-function; also, the otherwise constant object can only be written by a non-function. (Collect_Global_Item): The IN parameter can only be written when it belongs to non-function; also, unnest this check to make it easier to read.
-rw-r--r--gcc/ada/sem_prag.adb34
-rw-r--r--gcc/ada/sem_prag.ads6
2 files changed, 23 insertions, 17 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index b654495..0eb6ff6 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -1281,17 +1281,22 @@ package body Sem_Prag is
(Item_Is_Input : out Boolean;
Item_Is_Output : out Boolean)
is
- -- A constant or IN parameter of access-to-variable type should be
+ -- A constant or an IN parameter of a procedure or a protected
+ -- entry, if it is of an access-to-variable type, should be
-- handled like a variable, as the underlying memory pointed-to
-- can be modified. Use Adjusted_Kind to do this adjustment.
Adjusted_Kind : Entity_Kind := Ekind (Item_Id);
begin
- if Ekind (Item_Id) in E_Constant
- | E_Generic_In_Parameter
- | E_In_Parameter
+ if (Ekind (Item_Id) in E_Constant | E_Generic_In_Parameter
+ or else
+ (Ekind (Item_Id) = E_In_Parameter
+ and then Ekind (Scope (Item_Id))
+ not in E_Function | E_Generic_Function))
and then Is_Access_Variable (Etype (Item_Id))
+ and then Ekind (Spec_Id) not in E_Function
+ | E_Generic_Function
then
Adjusted_Kind := E_Variable;
end if;
@@ -30244,16 +30249,6 @@ package body Sem_Prag is
Formal := First_Entity (Spec_Id);
while Present (Formal) loop
if Ekind (Formal) in E_In_Out_Parameter | E_In_Parameter then
-
- -- IN parameters can act as output when the related type is
- -- access-to-variable.
-
- if Ekind (Formal) = E_In_Parameter
- and then Is_Access_Variable (Etype (Formal))
- then
- Append_New_Elmt (Formal, Subp_Outputs);
- end if;
-
Append_New_Elmt (Formal, Subp_Inputs);
end if;
@@ -30271,6 +30266,17 @@ package body Sem_Prag is
end if;
end if;
+ -- IN parameters of procedures and protected entries can act as
+ -- outputs when the related type is access-to-variable.
+
+ if Ekind (Formal) = E_In_Parameter
+ and then Ekind (Spec_Id) not in E_Function
+ | E_Generic_Function
+ and then Is_Access_Variable (Etype (Formal))
+ then
+ Append_New_Elmt (Formal, Subp_Outputs);
+ end if;
+
Next_Entity (Formal);
end loop;
diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads
index 1d58d06..75856c8 100644
--- a/gcc/ada/sem_prag.ads
+++ b/gcc/ada/sem_prag.ads
@@ -360,9 +360,9 @@ package Sem_Prag is
Subp_Outputs : in out Elist_Id;
Global_Seen : out Boolean);
-- Subsidiary to the analysis of pragmas Depends, Global, Refined_Depends
- -- and Refined_Global. The routine is also used by GNATprove. Collect all
- -- inputs and outputs of subprogram Subp_Id in lists Subp_Inputs (inputs)
- -- and Subp_Outputs (outputs). The inputs and outputs are gathered from:
+ -- and Refined_Global. Collect all inputs and outputs of subprogram Subp_Id
+ -- in lists Subp_Inputs (inputs) and Subp_Outputs (outputs). The inputs and
+ -- outputs are gathered from:
-- 1) The formal parameters of the subprogram
-- 2) The generic formal parameters of the generic subprogram
-- 3) The current instance of a concurrent type