[Ada] Fix assertion failure on functions with contracts

2020-06-10  Ghjuvan Lacambre  <lacambre@adacore.com>

gcc/ada/

	* par-ch6.adb (P_Subprogram): Make sure the specification
	belongs to a procedure.
This commit is contained in:
Ghjuvan Lacambre 2020-03-04 14:40:01 +01:00 committed by Pierre-Marie de Rodat
parent 3ea9566495
commit 057548bc5f
1 changed files with 6 additions and 3 deletions

View 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;