From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9869a3929132e322 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!h48g2000cwc.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: pragma import ambiguity Date: 7 Sep 2006 12:35:21 -0700 Organization: http://groups.google.com Message-ID: <1157657721.734036.128160@h48g2000cwc.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1157657727 12505 127.0.0.1 (7 Sep 2006 19:35:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Sep 2006 19:35:27 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h48g2000cwc.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:6503 Date: 2006-09-07T12:35:21-07:00 List-Id: 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