comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <lanceboyle@qwest.net>
Subject: Re: Selective suppression of warnings --- gnat on GNU/Linux
Date: Wed, 31 Dec 2008 11:46:08 -0800 (PST)
Date: 2008-12-31T11:46:08-08:00	[thread overview]
Message-ID: <79917534-5cc2-4f2e-9b9b-3bae7ba0cc18@r37g2000prr.googlegroups.com> (raw)
In-Reply-To: 7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com

On Dec 29, 8:13 pm, Michael Mounteney <gat...@landcroft.co.uk> 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:

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





  parent reply	other threads:[~2008-12-31 19:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-30  3:13 Selective suppression of warnings --- gnat on GNU/Linux Michael Mounteney
2008-12-30  8:03 ` Ludovic Brenta
2008-12-30 22:49   ` Michael Mounteney
2008-12-30 23:26     ` Robert A Duff
2008-12-30 11:01 ` (see below)
2008-12-30 11:37   ` Georg Bauhaus
2008-12-30 12:05     ` (see below)
2008-12-30 14:11       ` Pascal ranges (was: Selective suppression of warnings --- gnat on GNU/Linux) Georg Bauhaus
2008-12-30 20:19         ` (see below)
2008-12-30 23:19           ` Pascal ranges Robert A Duff
2008-12-30 23:34             ` (see below)
2008-12-31  0:07               ` Robert A Duff
2008-12-31  0:32                 ` (see below)
2008-12-30 23:13 ` Selective suppression of warnings --- gnat on GNU/Linux Robert A Duff
2008-12-31  9:46   ` Jean-Pierre Rosen
2008-12-31 14:55     ` Robert A Duff
2008-12-31 16:13       ` Jean-Pierre Rosen
2008-12-31 20:01         ` Robert A Duff
2008-12-31 18:43     ` (see below)
2008-12-31 19:49       ` Robert A Duff
2008-12-31 20:24         ` Jeffrey R. Carter
2008-12-31 22:38           ` Robert A Duff
2008-12-31 19:46 ` Jerry [this message]
2008-12-31 22:39   ` Robert A Duff
2008-12-31 23:37   ` Michael Mounteney
2009-01-01  9:45   ` sjw
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox