comp.lang.ada
 help / color / mirror / Atom feed
From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: pragma import ambiguity
Date: 7 Sep 2006 12:35:21 -0700
Date: 2006-09-07T12:35:21-07:00	[thread overview]
Message-ID: <1157657721.734036.128160@h48g2000cwc.googlegroups.com> (raw)
In-Reply-To: JGDLg.2382$O5.1258@llslave.llan.ll.mit.edu

Frank J. Lhota wrote:
> tmoran@acm.org wrote:
> > One Ada compiler accepts this, another doesn't. I agree with the one that
> > objects.  Are we wrong?
> > procedure testimp is
> >   type logicopenm is ( clear, gl_and);
> >   procedure clear(mask:integer);
> >   pragma import(stdcall,clear,"glclear");
> > begin
> >   null;
> > end testimp;
>
> This is a tough call. Technically, an enumeration literal such as "clear" in
>
> 	type logicopenm is ( clear, gl_and);
>
> is an implicit, parameterless function. Section B.1 of the ARM states
> "If the local_name denotes more than one entity, then the pragma Import
> is the completion of all of them", so one could argue that the import
> clause imports a subprogram for *both* the clear procedure and the
> enumeration literal. This is clearly not possible: the "clear"
> enumeration literal must be implicit.

Not quite; 3.5.1(6) says that the declaration of "clear" is explicit.
This makes a difference because of 3.11.1, which says that implicit
declarations may not have completions, but completions are allowed "in
principle" for any kind of explicit declaration, but only if there is
an implementation for that sort of declaration (B.1(22)).  Also, 6.3.1
says that the function declaration that arises from the enumeration
literal declaration has a default calling convention of Intrinsic, but
it also says that default calling conventions can be overridden,
although I can't see how it could make sense to override the default
calling convention for an enumeration literal, or for that matter most
or all of the other types of subprograms whose default calling
convention is Intrinsic.  So I'm not sure why the language allows this
"in principle".  Anyway, the language isn't clear on whether Import can
be applied to an enumeration literal.

I do believe, though, that it would be wrong for a compiler to reject
this:

    type logicopennm is (clear, gl_and);
    pragma import (stdcall, clear, "glclear");

when there's no overloading involved, but to accept the same pragma
when it can be applied both to a subprogram named "clear" and to the
enumeration literal.  The language does say that Import is the
completion of all entities denoted by the name, and if such a
completion is illegal for any denoted entity, then the compiler has to
reject the pragma.

                             -- Adam




  parent reply	other threads:[~2006-09-07 19:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06 16:05 pragma import ambiguity tmoran
2006-09-06 16:39 ` bubble
2006-09-06 16:42   ` bubble
2006-09-06 17:47   ` Pascal Obry
2006-09-21  1:26   ` Dave Thompson
2006-09-06 17:34 ` Frank J. Lhota
2006-09-06 18:06   ` Gautier
2006-09-07  7:53   ` Dmitry A. Kazakov
2006-09-07 19:35   ` Adam Beneschan [this message]
2006-09-08  3:48     ` Randy Brukardt
replies disabled

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