comp.lang.ada
 help / color / mirror / Atom feed
* generic instantion as overriding primitive operation?
@ 2012-10-21 17:52 Stephen Leake
  2012-10-23 14:58 ` Adam Beneschan
  2012-10-24 10:24 ` AdaMagica
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Leake @ 2012-10-21 17:52 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-24 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-21 17:52 generic instantion as overriding primitive operation? Stephen Leake
2012-10-23 14:58 ` Adam Beneschan
2012-10-24 10:11   ` Stephen Leake
2012-10-24 10:24 ` AdaMagica

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