[Ada] Check entries for formals of mode IN appearing as global outputs

Message ID 20210504095222.GA90360@adacore.com
State New
Headers show
Series
  • [Ada] Check entries for formals of mode IN appearing as global outputs
Related show

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m.
Rule SPARK RM 6.1.4(13) only mentions "subprograms", but it is equally
applicable to protected entries whose global inputs cannot appear as
global outputs in nested subprograms.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context):
	Extend check to protected entries.

Patch

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -2634,7 +2634,7 @@  package body Sem_Prag is
                   Context := Anonymous_Object (Context);
                end if;
 
-               if (Is_Subprogram (Context)
+               if (Is_Subprogram_Or_Entry (Context)
                      or else Ekind (Context) = E_Task_Type
                      or else Is_Single_Task_Object (Context))
                  and then
@@ -2659,7 +2659,7 @@  package body Sem_Prag is
                        ("global item & cannot have mode In_Out or Output",
                         Item, Item_Id);
 
-                     if Is_Subprogram (Context) then
+                     if Is_Subprogram_Or_Entry (Context) then
                         SPARK_Msg_NE
                           (Fix_Msg (Subp_Id, "\item already appears as input "
                            & "of subprogram &"), Item, Context);