[Ada] Fix assertion failure on functions with contracts
authorGhjuvan Lacambre <lacambre@adacore.com>
Wed, 4 Mar 2020 13:40:01 +0000 (14:40 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 10 Jun 2020 13:34:57 +0000 (09:34 -0400)
2020-06-10  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

* par-ch6.adb (P_Subprogram): Make sure the specification
belongs to a procedure.

gcc/ada/par-ch6.adb

index a43d673..abf7d10 100644 (file)
@@ -960,9 +960,12 @@ package body Ch6 is
 
          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
+            --  If the subprogram is a procedure and already has a
+            --  specification, we can't define another.
+
+            if Nkind (Specification (Decl_Node)) = N_Procedure_Specification
+              and then Null_Present (Specification (Decl_Node))
+            then
                Error_Msg_AP ("null procedure cannot have a body");
             end if;