comp.lang.ada
 help / color / mirror / Atom feed
* representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler.
@ 2018-03-24 17:16 Mehdi Saada
  2018-03-26 22:31 ` Randy Brukardt
  0 siblings, 1 reply; 4+ messages in thread
From: Mehdi Saada @ 2018-03-24 17:16 UTC (permalink / raw)


This is a translation from fr.c.l.a.

I wonder why in some cases where a generic formal type is a tagged type and has a known ancestor, one can alter the representation:

package AAA is
   type Type_A is tagged
      record
         INT: INTEGER;
      end record;
end AAA;
with AAA; use AAA;
generic
   type NT is new type_A with private;
package TENTATIVE is
   type B_Type is new Nt with null record with SIZE => 300;
   procedure P1 (B : B_Type) is NULL;
end TENTATIVE;
with AAA, TENTATIVE; use AAA;
procedure MAIN is
package TEST is new TENTATIVE(Type_A);
begin Null; end; 

It only gives me "main.adb:3:01: warning: in instantiation at tentative.ads:5
main.adb:3:01: warning: 172 bits of "B_Type" unused"

It compiles, while when the contract states that NT has only to be tagged, it failed.
To change "type NT is new TYPE_A with private" into "type NT is tagged private" gives "tentative.ads:5:48: representation item not allowed for generic type"

JPRosen couldn't help on this, and said you Randy could saw to it better ;-)


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

* Re: representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler.
  2018-03-24 17:16 representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler Mehdi Saada
@ 2018-03-26 22:31 ` Randy Brukardt
  2018-03-27 13:57   ` Jean-Claude Rostaing
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Brukardt @ 2018-03-26 22:31 UTC (permalink / raw)


No idea. It doesn't look right, but I don't know if that is an Ada or a 
compiler problem. Perhaps there is some rule which should have a special 
case for generic tagged private types, and doesn't.

                         Randy.


"Mehdi Saada" <00120260a@gmail.com> wrote in message 
news:d24fd816-10f4-48b3-b584-fe6589d38a62@googlegroups.com...
> This is a translation from fr.c.l.a.
>
> I wonder why in some cases where a generic formal type is a tagged type 
> and has a known ancestor, one can alter the representation:
>
> package AAA is
>   type Type_A is tagged
>      record
>         INT: INTEGER;
>      end record;
> end AAA;
> with AAA; use AAA;
> generic
>   type NT is new type_A with private;
> package TENTATIVE is
>   type B_Type is new Nt with null record with SIZE => 300;
>   procedure P1 (B : B_Type) is NULL;
> end TENTATIVE;
> with AAA, TENTATIVE; use AAA;
> procedure MAIN is
> package TEST is new TENTATIVE(Type_A);
> begin Null; end;
>
> It only gives me "main.adb:3:01: warning: in instantiation at 
> tentative.ads:5
> main.adb:3:01: warning: 172 bits of "B_Type" unused"
>
> It compiles, while when the contract states that NT has only to be tagged, 
> it failed.
> To change "type NT is new TYPE_A with private" into "type NT is tagged 
> private" gives "tentative.ads:5:48: representation item not allowed for 
> generic type"
>
> JPRosen couldn't help on this, and said you Randy could saw to it better 
> ;-) 



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

* Re: representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler.
  2018-03-26 22:31 ` Randy Brukardt
@ 2018-03-27 13:57   ` Jean-Claude Rostaing
  2018-03-27 23:59     ` Randy Brukardt
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Claude Rostaing @ 2018-03-27 13:57 UTC (permalink / raw)


How can I know if I shall report this to Adacore or not ?
It would be my first time. I anticipate and think of a special ritual or somethin', you see :-D


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

* Re: representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler.
  2018-03-27 13:57   ` Jean-Claude Rostaing
@ 2018-03-27 23:59     ` Randy Brukardt
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Brukardt @ 2018-03-27 23:59 UTC (permalink / raw)


If you're a customer, I'd report it and let them give you an answer. That's 
what you pay them for.

If you're not a customer, I'd still report it but don't expect an answer in 
any particular time.

                Randy.


"Jean-Claude Rostaing" <00120260a@gmail.com> wrote in message 
news:83ad49fb-1a17-4dc6-a717-0a350e61bcbf@googlegroups.com...
> How can I know if I shall report this to Adacore or not ?
> It would be my first time. I anticipate and think of a special ritual or 
> somethin', you see :-D 



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

end of thread, other threads:[~2018-03-27 23:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 17:16 representation clauses ok in generics when the formal type in tagged with known ancestor, but not ok when only know to be tagged ? ... said the compiler Mehdi Saada
2018-03-26 22:31 ` Randy Brukardt
2018-03-27 13:57   ` Jean-Claude Rostaing
2018-03-27 23:59     ` Randy Brukardt

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