comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Placement of pragma Convention
Date: 1997/06/23
Date: 1997-06-23T00:00:00+00:00	[thread overview]
Message-ID: <EC8x58.2uJ.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 5oervk$g07@newshub.atmnet.net


Christopher Green (cgreen@yosemite.atc.com) wrote:

: I have a question concerning the correct placement of pragma Convention;
: in particular, whether GNAT and other Ada 95 compilers are properly inter-
: preting the applicable rules.

: Given the following code:

: package Callbacks is

:     procedure OrdinaryProc;

: end Callbacks;

: package body Callbacks is

:     procedure OrdinaryProc is
:     begin
:         null;
:     end OrdinaryProc;

:     procedure CallbackProc is
:     begin
:         null;
:     end CallbackProc;
:     pragma Convention (C, CallbackProc);

: end Callbacks;

: I get the following different results when it is compiled on different Ada 95
: compilers.  All compilers are self-hosted on a SPARC/Solaris 2.5 host.

:     Apex 2.2.3A gives no errors and no warnings.

:     ObjectAda V7.1 gives no errors and no warnings.

:     GNAT 3.09 gives the following error:

:         callbacks.adb:12:05: pragma "Convention" requires separate spec and 
:         must come before body

: It would appear to me that the Apex and ObjectAda compilers are correct and
: the GNAT compiler is incorrect, ...

Despite my affiliation, GNAT is in the right on this one.
A program unit pragma may follow the program unit only if the
program unit is a subprogram_declaration, generic_subprogram_declaration,
or generic instantiation (10.1.5(4,6)).  In all other cases, it needs to be
immediately inside the program unit.  Although a "subprogram_body"
is considered to be a "declaration," it is *not* within the category 
"subprogram_declaration," and so any program unit pragma must
be immediately inside it, rather than following it.

Amusingly enough, at least in the recent past, Object Ada enforced
this rule for pragma Inline (which is also a program unit pragma)
and GNAT did not.

: ...
: Any "language lawyers" interested in commenting on the above, please respond
: by posting to this newsgroup or by e-mail.

See above.

: Chris Green                                  Email cgreen@atc.com
: Advanced Technology Center                   Phone (714) 583-9119
: 22982 Mill Creek Drive                                   ext. 220
: Laguna Hills, CA 92653                       Fax   (714) 583-9213

--
-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Burlington, MA  USA




  reply	other threads:[~1997-06-23  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-20  0:00 Placement of pragma Convention Christopher Green
1997-06-23  0:00 ` Tucker Taft [this message]
1997-06-23  0:00   ` Christopher Green
1997-06-24  0:00     ` Robert Dewar
replies disabled

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