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,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!r10g2000prf.googlegroups.com!not-for-mail From: Michael Mounteney Newsgroups: comp.lang.ada Subject: Selective suppression of warnings --- gnat on GNU/Linux Date: Mon, 29 Dec 2008 19:13:44 -0800 (PST) Organization: http://groups.google.com Message-ID: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> NNTP-Posting-Host: 192.18.17.40 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1230606824 3921 127.0.0.1 (30 Dec 2008 03:13:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 30 Dec 2008 03:13:44 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r10g2000prf.googlegroups.com; posting-host=192.18.17.40; posting-account=jBuPTAoAAABCn2rocutUgybAcLjD8f-Q User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.8.1.14) Gecko/20080616 Firefox/2.0.0.14,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:3113 Date: 2008-12-29T19:13:44-08:00 List-Id: 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: