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,WEIRD_QUOTING 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 Path: g2news1.google.com!postnews.google.com!r37g2000prr.googlegroups.com!not-for-mail From: Jerry Newsgroups: comp.lang.ada Subject: Re: Selective suppression of warnings --- gnat on GNU/Linux Date: Wed, 31 Dec 2008 11:46:08 -0800 (PST) Organization: http://groups.google.com Message-ID: <79917534-5cc2-4f2e-9b9b-3bae7ba0cc18@r37g2000prr.googlegroups.com> References: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> NNTP-Posting-Host: 75.171.45.240 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1230752769 27246 127.0.0.1 (31 Dec 2008 19:46:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 31 Dec 2008 19:46:09 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r37g2000prr.googlegroups.com; posting-host=75.171.45.240; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US) AppleWebKit/525.18 (KHTML, like Gecko, Safari/525.20) OmniWeb/v622.3.0.105198,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:3157 Date: 2008-12-31T11:46:08-08:00 List-Id: On Dec 29, 8:13=A0pm, 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. =A0The problem is > that the automatically-translated source is causing a lot of spurious > warnings about declarations not being used. =A0This is because the > Pascal code has many instances of: > > =A0 =A0 =A0type > =A0 =A0 =A0 =A0 =A0 somerange =3D 1..10; > =A0 =A0 =A0 =A0 =A0 somestruct =3D record ... end; > > which is translated into Ada as > > =A0 =A0 =A0type somerange is new integer range 1 .. 10; > > =A0 =A0 =A0type somestruct is record ... end record; > > but the problem is that any operators such as + and =3D are not visible > in other units. =A0The solution to that is to rename the operators in > the client units, thus: > > =A0 =A0 =A0with stage3; =A0 =A0-- contains definitions of somerange, some= struct > etc. > > =A0 =A0 =A0package body myusage is > > =A0 =A0 =A0 =A0 =A0 function "=3D" (L, R : in stage3.somestruct) return B= oolean > renames stage3."=3D"; > =A0 =A0 =A0 =A0 =A0 function "+" (L, R : in stage3.somerange) return > stage3.somerange renames stage3."+"; > =A0 =A0 =A0 =A0 =A0 .......... > =A0 =A0 =A0end myusage; > > without those renamings, any usage of =3D 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. =A0Thus, it produces the renaming clauses if it encounters > the type name is the source; =A0e.g., if it sees somerange, it outputs > all the renamings for somerange. =A0However, the renamings usually are > not required, so gnat warns about them. =A0Normally, this would not be a > problem; =A0one would simply remove the unneeded declaration from the > source. =A0I 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. =A0I don't want to switch off the warning > from the command line as that will suppress valid warnings. > > Is there another way ? =A0Is there some rearrangement of the source that > WOULD suppress the unwanted warnings. > > So the question: A quick read of this thread seems to indicate that the OP has not had his question answered, beyond "read the docs." Google reveals this Ada Gem of the Week from AdaCore: http://www.adacore.com/2007/11/19/ada-gem-18/ It shows how to turn off warnings for a particular range of code. From TFA: package body Warnings_Example is procedure Mumble (X : Integer) is begin null; end Mumble; end Warnings_Example; will cause GNAT to complain: warnings_example.adb:5:22: warning: formal parameter "X" is not referenced But the following will compile cleanly: package body Warnings_Example is pragma Warnings (Off, "formal parameter ""X"" is not referenced"); procedure Mumble (X : Integer) is pragma Warnings (On, "formal parameter ""X"" is not referenced"); -- X is ignored here, because blah blah blah... begin null; end Mumble; end Warnings_Example; Jerry