comp.lang.ada
 help / color / mirror / Atom feed
* User-Defined Reference in a Task Type Discriminant Compiler Bug?
@ 2013-03-21 15:11 Eryndlia Mavourneen
  2013-03-21 19:11 ` Shark8
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Eryndlia Mavourneen @ 2013-03-21 15:11 UTC (permalink / raw)


Dmitry spurred me to investigate user-defined references.

-----

1) The following code does not compile; however, it seems to abide by the LRM rules in 4.1.5:

   type Inc_Type is not null access procedure (To_Increment : in out Integer);
   
   task type T (Incrementing_Procedure : Inc_Type)
   with Implicit_Dereference => Incrementing_Procedure;

and fails with the error

   not an access discriminant of "T"

referencing the aspect clause.

-----

2) Adding "access" before the discriminant type in the task declaration compiles:

   type Inc_Type is not null access procedure (To_Increment : in out Integer);
   
   task type T (Incrementing_Procedure : access Inc_Type)
   with Implicit_Dereference => Incrementing_Procedure;

but I believe that this will produce an access of an access, no?  The declaration of Inc_Type is not possible, of course, without the keyword "access".

-----

3) I tried pleasing the compiler by splitting the declaration, as:

   type Inc_Type is access procedure (To_Increment : in out Integer);
   
   task type T (Incrementing_Procedure : not null Inc_Type)
   with Implicit_Dereference => Incrementing_Procedure;

but Gnat still produces the same error message for the aspect.

-----

Note that the declaration of Inc_Type in (1) is properly recognized as an access-to-subprogram type without the aspect clause.  I find it odd that the declaration of the discriminant + aspect clause given a similar circumstance will not compile.  It appears to prevent implicitly the type of construct in (1), which seems to me to be legal Ada code.

-----

Eryndlia F. Mavourneen



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

end of thread, other threads:[~2013-03-22  1:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-21 15:11 User-Defined Reference in a Task Type Discriminant Compiler Bug? Eryndlia Mavourneen
2013-03-21 19:11 ` Shark8
2013-03-21 19:12 ` Adam Beneschan
2013-03-21 19:43   ` Simon Wright
2013-03-21 23:49 ` Randy Brukardt
2013-03-22  1:15 ` Eryndlia Mavourneen

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