An illegal item appearing in the Global contract but missing from the
Depends contract was crashing the compiler.

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

gcc/ada/

        * sem_prag.adb (Check_Usage): Guard against calling Usage_Error
        with illegal Item_Id. The intention to do this was already
        described in the comment but not implemented.
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
@@ -1684,7 +1684,15 @@ package body Sem_Prag is
                --  States and global objects are not used properly only when
                --  the subprogram is subject to pragma Global.
 
-               elsif Global_Seen then
+               elsif Global_Seen
+                 and then Ekind (Item_Id) in E_Abstract_State
+                                           | E_Constant
+                                           | E_Loop_Parameter
+                                           | E_Protected_Type
+                                           | E_Task_Type
+                                           | E_Variable
+                                           | Formal_Kind
+               then
                   Usage_Error (Item_Id);
                end if;
             end if;


Reply via email to