aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhjuvan Lacambre <lacambre@adacore.com>2020-03-04 14:40:01 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-10 09:34:57 -0400
commit057548bc5f3a067f881cd6985419956b0f2696fc (patch)
tree92f01d2607f3eeb47b97db41ab8c8b739b7a8cee
parent3ea95664954775a1a85c9ea097877754984807aa (diff)
downloadgcc-057548bc5f3a067f881cd6985419956b0f2696fc.zip
gcc-057548bc5f3a067f881cd6985419956b0f2696fc.tar.gz
gcc-057548bc5f3a067f881cd6985419956b0f2696fc.tar.bz2
[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.
-rw-r--r--gcc/ada/par-ch6.adb9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
index a43d673..abf7d10 100644
--- a/gcc/ada/par-ch6.adb
+++ b/gcc/ada/par-ch6.adb
@@ -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;