Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Avoid strange women and temporary variables.


devel / comp.lang.ada / Safe to ignore warnings about function mistaken as primitive?

SubjectAuthor
* Safe to ignore warnings about function mistaken as primitive?G.B.
+- Re: Safe to ignore warnings about function mistaken as primitive?Dmitry A. Kazakov
`* Re: Safe to ignore warnings about function mistaken as primitive?Stephen Leake
 `- Re: Safe to ignore warnings about function mistaken as primitive?G.B.

1
Safe to ignore warnings about function mistaken as primitive?

<tae3j4$1b95n$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8506&group=comp.lang.ada#8506

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: bauhaus@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Safe to ignore warnings about function mistaken as primitive?
Date: Sun, 10 Jul 2022 10:45:24 +0200
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <tae3j4$1b95n$1@dont-email.me>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 10 Jul 2022 08:45:24 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="17748d9030baab970700b86cc04aab06";
logging-data="1418423"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TGx6WzPYamWe7/4aQZEloaJ+rwJqXnzg="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.11.0
Cancel-Lock: sha1:PIY2TzrtdkmzJrfHIEgyyBYKYVs=
Content-Language: en-US
 by: G.B. - Sun, 10 Jul 2022 08:45 UTC

GNAT warns about primitive operations appearing too late in the text.
In the following example, though, F is not meant to be a primitive
operation of A.Some_Tagged, but instead one of type B.Plain.

Can I ignore the warning?

gcc -gnatl -c rt_warn.ads

GNAT 11.2.0
Copyright 1992-2021, Free Software Foundation, Inc.
cannot generate code for file rt_warn.ads (package spec)

Compiling: rt_warn.ads
Source file time stamp: 2022-07-10 08:34:32
Compiled at: 2022-07-10 10:34:39

1. package Rt_Warn is
2.
3. package A is
4.
5. type Some_Tagged is interface;
6.
7. end A;
8.
9. package B is
10.
11. type Plain is private;
12.
13. function F (Param : A.Some_Tagged) return Plain;
|
>>> warning: declaration of "F" is too late
>>> warning: spec should appear immediately after declaration of "Some_Tagged"

14. function FC (Param : A.Some_Tagged'Class) return Plain;
15. private
16. type Plain is record
17. null;
18. end record;
19. end B;
20.
21. end Rt_Warn;

21 lines: No errors, 2 warnings

Re: Safe to ignore warnings about function mistaken as primitive?

<tae92v$ucm$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8507&group=comp.lang.ada#8507

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!l6SSJpCTNdcdYkpTNEWC9Q.user.46.165.242.91.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Safe to ignore warnings about function mistaken as primitive?
Date: Sun, 10 Jul 2022 12:19:11 +0200
Organization: Aioe.org NNTP Server
Message-ID: <tae92v$ucm$1@gioia.aioe.org>
References: <tae3j4$1b95n$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="31126"; posting-host="l6SSJpCTNdcdYkpTNEWC9Q.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.11.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Sun, 10 Jul 2022 10:19 UTC

On 2022-07-10 10:45, G.B. wrote:
> GNAT warns about primitive operations appearing too late in the text.
> In the following example, though, F is not meant to be a primitive
> operation of A.Some_Tagged, but instead one of type B.Plain.
>
> Can I ignore the warning?
>
> gcc -gnatl -c rt_warn.ads
>
> GNAT 11.2.0
> Copyright 1992-2021, Free Software Foundation, Inc.
> cannot generate code for file rt_warn.ads (package spec)
>
>
> Compiling: rt_warn.ads
> Source file time stamp: 2022-07-10 08:34:32
> Compiled at: 2022-07-10 10:34:39
>
>      1. package Rt_Warn is
>      2.
>      3.     package A is
>      4.
>      5.         type Some_Tagged is interface;
>      6.
>      7.     end A;
>      8.
>      9.     package B is
>     10.
>     11.         type Plain is private;
>     12.
>     13.         function F (Param : A.Some_Tagged) return Plain;
>                          |
>         >>> warning: declaration of "F" is too late
>         >>> warning: spec should appear immediately after declaration
> of "Some_Tagged"

Some_Tagged is an interface, it cannot have implementations anyway.
Should be an error rather than just warning to me.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Safe to ignore warnings about function mistaken as primitive?

<864jzoclzv.fsf@stephe-leake.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8508&group=comp.lang.ada#8508

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!6MpDoNrA+2KoZyE4OD7oYg.user.46.165.242.75.POSTED!not-for-mail
From: stephen_leake@stephe-leake.org (Stephen Leake)
Newsgroups: comp.lang.ada
Subject: Re: Safe to ignore warnings about function mistaken as primitive?
Date: Sun, 10 Jul 2022 21:27:16 -0700
Organization: Aioe.org NNTP Server
Message-ID: <864jzoclzv.fsf@stephe-leake.org>
References: <tae3j4$1b95n$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: gioia.aioe.org; logging-data="44424"; posting-host="6MpDoNrA+2KoZyE4OD7oYg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:/YWa0qUC2WEiv9LLwaJjMQlrDwQ=
 by: Stephen Leake - Mon, 11 Jul 2022 04:27 UTC

"G.B." <bauhaus@notmyhomepage.invalid> writes:

> GNAT warns about primitive operations appearing too late in the text.
> In the following example, though, F is not meant to be a primitive
> operation of A.Some_Tagged, but instead one of type B.Plain.
>
> Can I ignore the warning?

It's best to never ignore warnings, but instead fix them. Even if the
only way to "fix" it is to add "pragma Warnings (Off ...)"; that at
least tells the reader you have considered the warning.

Since B.F is declared in a sibling package, it cannot a primitive of
A.Some_Tagged, so the error message is wrong.

Since A.Some_Tagged is an interface, you can only declare abstract
primitive subprograms for it. So I suspect GNAT knows there's an error, but is
giving a confusing error message.

How are you intending F to be different from FC?

--
-- Stephe

Re: Safe to ignore warnings about function mistaken as primitive?

<tah7tp$1n5he$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=8510&group=comp.lang.ada#8510

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: bauhaus@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Re: Safe to ignore warnings about function mistaken as primitive?
Date: Mon, 11 Jul 2022 15:17:44 +0200
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <tah7tp$1n5he$1@dont-email.me>
References: <tae3j4$1b95n$1@dont-email.me> <864jzoclzv.fsf@stephe-leake.org>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 11 Jul 2022 13:17:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="643526d1fcf5a8d0557ae19a8e2d2be2";
logging-data="1807918"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hLBDDluYp+nmH9tHi45yhMfyamIxvaIo="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.11.0
Cancel-Lock: sha1:Ke2N0FCmvyVkGFP3L6I2v++64DI=
In-Reply-To: <864jzoclzv.fsf@stephe-leake.org>
Content-Language: en-US
 by: G.B. - Mon, 11 Jul 2022 13:17 UTC

On 11.07.22 06:27, Stephen Leake wrote:

> Since B.F is declared in a sibling package, it cannot a primitive of
> A.Some_Tagged, so the error message is wrong.
>
> Since A.Some_Tagged is an interface, you can only declare abstract
> primitive subprograms for it. So I suspect GNAT knows there's an error, but is
> giving a confusing error message.

It seems possible to write programs declaring B.F (Param : A.Some_Tagged)...,
but hardly one that isn't pointless! Adding "in out" to the
function's Param allows 'Access using 'Class renames Ref'(Param'Access).all
and then 'Unchecked_Access---so twisted I shan't repeat it here.
Adding (... : access A.Some_Tagged) works a lot better (of course <:-|),
and still has the warning.

But, GNAT is right, I think!

> How are you intending F to be different from FC?

The first F was a bad choice, I guess; I had wanted to exclude a potentially
larger interface. FC was the beginning of dropping F.
FC now takes an access to class-wide.

With Op1 added to the interface of Some_Tagged,

package B is
type Plain(<>) is private;

function FC (Param : access A.Some_Tagged'Class) return Plain;
procedure G (Item : in out Plain; Param : in Character);
-- Calls Op1 of Item.Client
private
type Plain (Client : access A.Some_Tagged'Class) is record
null;
end record;
end B;

No F, no warning.


devel / comp.lang.ada / Safe to ignore warnings about function mistaken as primitive?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor