comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
Subject: generic instantion as overriding primitive operation?
Date: Sun, 21 Oct 2012 13:52:56 -0400
Date: 2012-10-21T13:52:56-04:00	[thread overview]
Message-ID: <858vazhfuv.fsf@stephe-leake.org> (raw)

The syntax for generic_instantiation allows an overriding_indicator:

     generic_instantiation ::= 
          [overriding_indicator]
          procedure defining_program_unit_name is
              new generic_procedure_name [generic_actual_part]
                 [aspect_specification];

So I'm trying to construct an example of that, as a test for the Ada
mode 5.0 indentation engine.

So far I have:

package Ada_Mode.Nominal is
   type Parent_Type_1 is tagged null record;
   procedure Procedure_1a (Item  : in out Parent_Type_1);
   function Function_2a (Param : in Parent_Type_1) return Float;
end Ada_Mode.Nominal;

generic
package Ada_Mode.Generic_Parent is

   -- These match some of the primitive operations of
   -- Ada_Mode.Nominal.Parent_Type_1.
   
   generic
      type Tagged_Type is abstract tagged limited private;
   function Gen_Function_2a (Item : in Tagged_Type) return Float;

   generic
      type Tagged_Type is abstract tagged limited private;
   procedure Gen_Procedure_1b (Item : in out Tagged_Type);
   
end Ada_Mode.Generic_Parent;


with Ada_Mode.Generic_Parent;
with Ada_Mode.Nominal;
package Ada_Mode.Generic_Instantiation is

   package Instance is new Ada_Mode.Generic_Parent;

   type Child_Type_1 is new Ada_Mode.Nominal.Parent_Type_1 with null record;

   overriding
   procedure Procedure_1b is new Instance.Gen_Procedure_1b (Child_Type_1);

   type Child_Type_2 is new Ada_Mode.Nominal.Parent_Type_1 with null record;

   overriding
   function Function_2a is new Instance.Gen_Function_2a (Child_Type_2);

end Ada_Mode.Generic_Instantiation;

But GNAT 7.0.1 doesn't like this; it says:

ada_mode-generic_instantiation.ads:32:04: warning: no primitive operations for "Child_Type_1" after this line
ada_mode-generic_instantiation.ads:32:14: this primitive operation is declared too late

where 'line 32' is the line declaring Procedure_1b

Can anyone rearrange this to make it compile? Or is this a compiler bug?

Does anyone have any real examples of this?

-- 
-- Stephe



             reply	other threads:[~2012-10-21 17:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-21 17:52 Stephen Leake [this message]
2012-10-23 14:58 ` generic instantion as overriding primitive operation? Adam Beneschan
2012-10-24 10:11   ` Stephen Leake
2012-10-24 10:24 ` AdaMagica
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox