comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: pragma Convention questions
Date: Wed, 14 Nov 2007 23:06:37 -0600
Date: 2007-11-14T23:06:37-06:00	[thread overview]
Message-ID: <fhgjug$e3m$1@jacob-sparre.dk> (raw)
In-Reply-To: 87sl3cd9cw.fsf@willow.rfc1149.net

"Samuel Tardieu" <sam@rfc1149.net> wrote in message
news:87sl3cd9cw.fsf@willow.rfc1149.net...
> I have several questions regarding pragma Convention in Ada95 for
> language lawyers.
>
> 1- pragma Convention on private types in language-define packages
>
> Is it allowed for a compiler implementor to use a pragma Convention
> on a private type in a language-defined package?

I would say that is not allowed, because it could cause portability problems
between implementations. But I don't have any RM reference for that opinion,
so if you really care you'll need to ask on Ada-Comment. Also:

> For example, would it be allowed to use
>
>   pragma Convention (C, chars_ptr);
>
> in the private part of Interfaces.C.Strings? (the real motive to this
> question is to get rid of a warning in GNAT about conversion between
> pointers of different conventions -- the type is already compatible
> with C as per RM B3.1(1))

I think in this case, you could never tell the difference, so it would be OK
to do. (One wonders why the Standard didn't include that in the first
place.)

> 2- pragma Convention, renaming and Intrinsic
>
> Is the following code legal?
>
> package U is
>    type Foo is (Foo1, Foo2);
>    function F return Foo renames Foo1;
>    pragma Convention (Ada, F);
>    type Foo_Access is access function return Foo;
>    X : Foo_Access := F'Access;
> end U;
>
> GNAT rejects X initialization with 'prefix of "Access" attribute
> cannot be intrinsic'. Which means that the pragma Convention failed
> silently. Is it allowed to have it fail without a compilation error?
> Or is the 'Access legal?

I think that it should either work or the pragma Convention should be
rejected. To allow the change of the convention to one that is legal and
still reject the 'Access is bogus. (OTOH, this doesn't seem like a very
important bug, and I would not be surprised if it took a long time to get
fixed.)

                                   Randy.





  parent reply	other threads:[~2007-11-15  5:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-11 16:39 pragma Convention questions Samuel Tardieu
2007-11-11 19:14 ` Martin Krischik
2007-11-11 20:57   ` Samuel Tardieu
2007-11-12  8:14     ` Martin Krischik
2007-11-12  8:30       ` Samuel Tardieu
2007-11-12 17:02 ` Adam Beneschan
2007-11-12 21:54   ` Samuel Tardieu
2007-11-15  5:06 ` Randy Brukardt [this message]
2007-11-15  7:55   ` Samuel Tardieu
replies disabled

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