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,d679dd7e9c16805a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!s1g2000prg.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Selective suppression of warnings --- gnat on GNU/Linux Date: Tue, 30 Dec 2008 00:03:52 -0800 (PST) Organization: http://groups.google.com Message-ID: <57b8ccae-e5b8-448e-a6d1-86145fc4d03c@s1g2000prg.googlegroups.com> References: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> NNTP-Posting-Host: 88.170.86.208 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1230624232 25505 127.0.0.1 (30 Dec 2008 08:03:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 30 Dec 2008 08:03:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s1g2000prg.googlegroups.com; posting-host=88.170.86.208; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.18) Gecko/20081030 Iceape/1.1.13 (Debian-1.1.13-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:4085 Date: 2008-12-30T00:03:52-08:00 List-Id: On Dec 30, 4:13 am, Michael Mounteney wrote: > Hello, I am trying to build an application of which some of the source > is automatically translated from Pascal, on the fly. The problem is > that the automatically-translated source is causing a lot of spurious > warnings about declarations not being used. This is because the > Pascal code has many instances of: > > type > somerange = 1..10; > somestruct = record ... end; > > which is translated into Ada as > > type somerange is new integer range 1 .. 10; > > type somestruct is record ... end record; > > but the problem is that any operators such as + and = are not visible > in other units. The solution to that is to rename the operators in > the client units, thus: > > with stage3; -- contains definitions of somerange, somestruct > etc. > > package body myusage is > > function "=" (L, R : in stage3.somestruct) return Boolean > renames stage3."="; > function "+" (L, R : in stage3.somerange) return > stage3.somerange renames stage3."+"; > .......... > end myusage; > > without those renamings, any usage of = and + within the body of > myusage are flagged as errors owing to lack of visibility/ > qualification. > > The translator is a rather crude line-by-line affair written in > Haskell that only performs partial analysis of the source, and > certainly isn't up to identifying the arguments to operators within > expressions. Thus, it produces the renaming clauses if it encounters > the type name is the source; e.g., if it sees somerange, it outputs > all the renamings for somerange. However, the renamings usually are > not required, so gnat warns about them. Normally, this would not be a > problem; one would simply remove the unneeded declaration from the > source. I did try putting the declarations into another package and > then "with" and "use" that, but then the warning changes to "no > declarations used from the package". > > I really really really don't like "use" anyway and prefer always to > qualify imported names. > > What I'd like is a pragma that switches-off and switches-on the > warning over the specific range of lines containing the renamings, but > no such seems to be available. I don't want to switch off the warning > from the command line as that will suppress valid warnings. > > Is there another way ? Is there some rearrangement of the source that > WOULD suppress the unwanted warnings. > > So the question: Have you tried replacing the renaming declarations with "use type somerange;" ? One such clause applies to all operators. You will get fewer warnings, as if a single operator is used then the "use type" clause does not cause a warning. -- Ludovic Brenta.