Patchwork [Ada] overriding indicator in subunit

login
register
mail settings
Submitter Arnaud Charlet
Date June 14, 2010, 1:33 p.m.
Message ID <20100614133306.GA11539@adacore.com>
Download mbox | patch
Permalink /patch/55530/
State New
Headers show

Comments

Arnaud Charlet - June 14, 2010, 1:33 p.m.
The parser did not correctly recognize "overriding"
and "not overriding" in a subunit.

The following test should compile silently.

package Subunits is

   type T is null record;

   not overriding
   procedure Not_Overriding (X : T);

end Subunits;

package body Subunits is

   not overriding
   procedure Not_Overriding (X : T) is separate;

end Subunits;

separate (Subunits)
not overriding
procedure Not_Overriding (X : T) is
begin
   null;
end Not_Overriding;

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

2010-06-14  Bob Duff  <duff@adacore.com>

	* par-ch10.adb (P_Subunit): If the next token after "separate(X)" is
	Tok_Not or Tok_Overriding, call P_Subprogram. We had previously given
	the incorrect error "proper body expected".
	* par-ch6.adb (P_Subprogram): Suppress "overriding indicator not
	allowed here" error in case of subunits, which was triggered by the
	above change to P_Subunit.

Patch

Index: par-ch6.adb
===================================================================
--- par-ch6.adb	(revision 160705)
+++ par-ch6.adb	(working copy)
@@ -215,14 +215,17 @@  package body Ch6 is
          --  already been given, so no need to give another message here.
 
          --  An overriding indicator is allowed for subprogram declarations,
-         --  bodies, renamings, stubs, and instantiations. The test against
-         --  Pf_Decl_Pbod is added to account for the case of subprograms
-         --  declared in a protected type, where only subprogram declarations
-         --  and bodies can occur.
+         --  bodies (including subunits), renamings, stubs, and
+         --  instantiations. The test against Pf_Decl_Pbod is added to account
+         --  for the case of subprograms declared in a protected type, where
+         --  only subprogram declarations and bodies can occur. The Pf_Pbod
+         --  case is for subunits.
 
          if Pf_Flags /= Pf_Decl_Gins_Pbod_Rnam_Stub
               and then
             Pf_Flags /= Pf_Decl_Pbod
+              and then
+            Pf_Flags /= Pf_Pbod
          then
             Error_Msg_SC ("overriding indicator not allowed here!");
 
Index: par-ch10.adb
===================================================================
--- par-ch10.adb	(revision 160705)
+++ par-ch10.adb	(working copy)
@@ -1028,7 +1028,11 @@  package body Ch10 is
 
       Ignore (Tok_Semicolon);
 
-      if Token = Tok_Function or else Token = Tok_Procedure then
+      if Token = Tok_Function
+        or else Token = Tok_Not
+        or else Token = Tok_Overriding
+        or else Token = Tok_Procedure
+      then
          Body_Node := P_Subprogram (Pf_Pbod);
 
       elsif Token = Tok_Package then