From: anon@anon.org
Subject: Re: Warnings about hiding
Date: Sat, 9 Oct 2010 11:18:37 +0000 (UTC)
Date: 2010-10-09T11:18:37+00:00 [thread overview]
Message-ID: <i8pj2b$2gsj$1@news.ett.com.ua> (raw)
In-Reply-To: 44e7dff1-04f5-46ad-8521-e4fe030c9c29@26g2000yqv.googlegroups.com
In <44e7dff1-04f5-46ad-8521-e4fe030c9c29@26g2000yqv.googlegroups.com>, Julian Leyh <julian@vgai.de> writes:
>Hi,
>
>"-gnatwh" activates warnings on hiding declarations. But sometimes,
>hiding is necessary.
>
>For example, consider this (Controlled type with it's own comparison
>operator and finalize procedure, you can reproduce the errors using
>these ads files):
>
>$ cat foo.ads
>with Ada.Finalization;
>package foo is
> type Foobar is new Ada.Finalization.Controlled with null record;
> function "=" (L,R : in Foobar) return Boolean;
>private
> procedure Finalize (Object : in out Foobar);
>end foo;
>$ gnat -gnatwh -gnatc foo.ads
>gcc -c -gnatwh -gnatc foo.ads
>foo.ads:4:13: warning: declaration of "=" hides one in package
>Standard
>foo.ads:6:14: warning: declaration of "Finalize" hides one at line 3
>$
>
>The only way i see to solve this, is using pragma Warnings (Off); like
>this:
>
>$ cat bar.ads
>with Ada.Finalization;
>package bar is
> type Barfoo is new Ada.Finalization.Controlled with null record;
>pragma Warnings(Off);
> function "=" (L,R : in Barfoo) return Boolean;
>pragma Warnings(On);
>private
> procedure Finalize (Object : in out Barfoo);
>end bar;
>$ gnatmake -gnatc -gnatwh bar.ads
>gcc -c -gnatwh -gnatc bar.ads
>bar.ads:8:14: warning: declaration of "Finalize" hides one at line 3
>$
>
>But that would either remove all warnings between both pragmas, or I
>would have to put them around every occurence of the hiding. I don't
>like turning all warnings off at once and I don't like adding two
>lines of source code just to prevent the warning. Still, I would like
>to remove them (without removing -gnatwh).
>
>Is there a proper way to do this?
>
>Greetings,
>Julian
RM 8.3 (19) defines your problem. In your example there is no fix. Your
just trying to violate Ada's visibility rules is all.
Plus, the "-gnatwh" just states which routines or variables that are hidden by
redefinition or overloading routines and variables.
So, drop the requirement of using "-gnatwh" is the only answer. Unless you
want or need to see what caused the first routine or variable to be hidden.
To see a better example of this. Copy s-fileio.ad? (System.File_io.ad?) to a
test directory and compile using "-gnatwh". I chose s-fileio.ad? because it
has and similar code as your example. In compiling you will get all kinds
of warning messages about like
"declaration hides "SSL" at a-except.ads"
or
"declaration of "Finalize" hides one at line"
next prev parent reply other threads:[~2010-10-09 11:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-08 12:47 Warnings about hiding Julian Leyh
2010-10-08 19:46 ` Adam Beneschan
2010-10-08 20:24 ` Simon Wright
2010-10-09 1:31 ` Vinzent Hoefler
2010-10-09 6:51 ` Randy Brukardt
2010-10-09 8:08 ` Dmitry A. Kazakov
2010-10-26 1:34 ` Yannick Duchêne (Hibou57)
2010-10-26 1:28 ` Yannick Duchêne (Hibou57)
2010-10-09 11:18 ` anon [this message]
2010-10-09 19:11 ` Simon Wright
2010-10-09 20:11 ` anon
2010-10-26 1:16 ` Yannick Duchêne (Hibou57)
2010-10-26 9:32 ` J-P. Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox