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 <[email protected]>
* sem_ch6.adb (Analyze_Null_Procedure): Reject a null procedure
that there is a previous null procedure in scope with a matching
profile.
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);