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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,29523eff834b8169 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news1.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Warnings about hiding Date: Tue, 26 Oct 2010 03:16:02 +0200 Organization: Ada @ Home Message-ID: References: <44e7dff1-04f5-46ad-8521-e4fe030c9c29@26g2000yqv.googlegroups.com> NNTP-Posting-Host: o1huFJB2ANcHlWoNFASSiA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.63 (Win32) Xref: g2news1.google.com comp.lang.ada:14769 Date: 2010-10-26T03:16:02+02:00 List-Id: Le Fri, 08 Oct 2010 14:47:05 +0200, Julian Leyh a =C3=A9= crit: > 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 "=3D" (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 "=3D" 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 "=3D" (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? (warnings check may be rough, this is less trustable than a conformance = to = the language semantic) Yes, there is a cleaner way to do this : use AdaControl, which allow fin= er = level of control. http://adalog.pagesperso-orange.fr/adacontrol2.htm You may either make a request to Jean-Pierre Rosen for commercial suppor= t, = that is, to add this particular test in AdaControl's capabilities or els= e = use the source (which is provided) to add your own hook (the source is = mostly well designed and readable). -- = Si les chats miaulent et font autant de vocalises bizarres, c=E2=80=99es= t pas pour = les chiens.