[Ada] Reject Global/Depends contracts on null procedures
authorYannick Moy <moy@adacore.com>
Mon, 28 Sep 2020 15:58:31 +0000 (17:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 24 Nov 2020 10:15:59 +0000 (05:15 -0500)
gcc/ada/

* sem_prag.adb (Analyze_Depends_Global): Reject Global and
Depends on null procedure.

gcc/ada/sem_prag.adb

index 1e1a279da2e95175aa2647470fede2d29162ccc2..c64bf48167fdb6e497d0df2b26a75717d061c131 100644 (file)
@@ -4437,7 +4437,17 @@ package body Sem_Prag is
          --  Subprogram declaration
 
          elsif Nkind (Subp_Decl) = N_Subprogram_Declaration then
-            null;
+
+            --  Pragmas Global and Depends are forbidden on null procedures
+            --  (SPARK RM 6.1.2(2)).
+
+            if Nkind (Specification (Subp_Decl)) = N_Procedure_Specification
+              and then Null_Present (Specification (Subp_Decl))
+            then
+               Error_Msg_N (Fix_Error
+                 ("pragma % cannot apply to null procedure"), N);
+               return;
+            end if;
 
          --  Task type