[Ada] Reject illegal bodies for null procedures
authorGhjuvan Lacambre <lacambre@adacore.com>
Mon, 2 Mar 2020 11:41:52 +0000 (12:41 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 10 Jun 2020 13:34:55 +0000 (09:34 -0400)
2020-06-10  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

* par-ch6.adb (P_Subprogram): Reject duplicate subprogram
declarations.

gcc/ada/par-ch6.adb

index 2cc3f08f94a27103e3f6094694afb1cc5c68615b..a43d6735668e7184e43a7d8fb0c2f5b113011682 100644 (file)
@@ -959,6 +959,13 @@ package body Ch6 is
          --  the collected aspects, if any, to the body.
 
          if Token = Tok_Is then
+
+            --  If the subprogram declaration already has a specification, we
+            --  can't define another.
+            if Null_Present (Specification (Decl_Node)) then
+               Error_Msg_AP ("null procedure cannot have a body");
+            end if;
+
             Scan;
             goto Subprogram_Body;