diff mbox

[Ada] Reject illegal null procedure

Message ID 20141107134857.GA7717@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Nov. 7, 2014, 1:48 p.m. UTC
In Ada 2012 a null procedure can be a completion, but it cannot be the
completion of a previous null procedure with the same profile

Compiling p.adb must yield:

   p.adb:7:04: duplicate body for "Q" declared at p.ads:6
   p.adb:12:04: duplicate body for "Q1" declared at p.ads:7

---
package P is

   function F
      return Boolean;

   procedure Q is null;
   procedure Q1 is null;

end P;
---
package body P is

   function F
      return Boolean is (True);

   procedure Q is
   begin
      null;
   end Q;

   procedure Q1 is null;
end P;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-11-07  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Analyze_Null_Procedure): Reject a null procedure
	that there is a previous null procedure in scope with a matching
	profile.
diff mbox

Patch

Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 217215)
+++ sem_ch6.adb	(working copy)
@@ -1453,6 +1453,11 @@ 
          --  there are various error checks that are applied on this body
          --  when it is analyzed (e.g. correct aspect placement).
 
+         if Has_Completion (Prev) then
+            Error_Msg_Sloc := Sloc (Prev);
+            Error_Msg_NE ("duplicate body for & declared#", N, Prev);
+         end if;
+
          Is_Completion := True;
          Rewrite (N, Null_Body);
          Analyze (N);