[gcc(refs/users/aoliva/heads/testme)] [Ada] Fix assertion failure on functions with contracts

Alexandre Oliva aoliva@gcc.gnu.org
Wed Jun 10 21:21:57 GMT 2020


https://gcc.gnu.org/g:057548bc5f3a067f881cd6985419956b0f2696fc

commit 057548bc5f3a067f881cd6985419956b0f2696fc
Author: Ghjuvan Lacambre <lacambre@adacore.com>
Date:   Wed Mar 4 14:40:01 2020 +0100

    [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.

Diff:
---
 gcc/ada/par-ch6.adb | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
index a43d6735668..abf7d1052e3 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;


More information about the Gcc-cvs mailing list