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.2 required=5.0 tests=BAYES_00,FROM_LOCAL_HEX, FROM_STARTS_WITH_NUMS autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,85e39962c3b81741,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news4.google.com!feeder.news-service.com!newsfeed101.telia.com!starscream.dk.telia.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> Newsgroups: comp.lang.ada Subject: GNATCheck and pragma Annotate Date: Fri, 29 Jul 2011 19:11:12 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net jeMyfhgk1hgkcSvL/10ZEgN5jTN8OIvmygyTxDlLx8eamS8GAI Cancel-Lock: sha1:md4qj/V7MXTt3F41FmhuoxRsOYU= User-Agent: Opera Mail/11.50 (Win32) Xref: g2news1.google.com comp.lang.ada:20415 Date: 2011-07-29T19:11:12+02:00 List-Id: Hi, I was recently trying to implement some coding standard rules based on gnatcheck and ran into a problem with the "Annotate pragma". Following simple example shall show the problem: -- 8< -- procedure Test_Subtypes is pragma Suppress (All_Checks); subtype A is Integer range 1 .. 5; begin null; end Test_Subtypes; -- 8< -- Now I don't want dependence on predefined numeric types and initially disallow any use of pragmas: $ gnatcheck test_subtypes.adb -rules +RPredefined_Numeric_Types +RForbidden_Pragmas:ALL test_subtypes.adb:3:4: use of pragma Suppress test_subtypes.adb:5:17: explicit reference to predefined numeric subtype So far, so good. Now, let's say, I want to silence down the rule check on this particular type declaration. So, there's the Annotate pragma: -- 8< -- pragma Suppress (All_Checks); pragma Annotate (gnatcheck, Exempt_On, "Predefined_Numeric_Types", "We need it here."); subtype A is Integer range 1 .. 5; pragma Annotate (gnatcheck, Exempt_Off, "Predefined_Numeric_Types"); -- 8< -- $ gnatcheck src/test_subtypes.adb -rules +RPredefined_Numeric_Types +RForbidden_Pragmas:ALL test_subtypes.adb:3:4: use of pragma Suppress test_subtypes.adb:5:4: use of pragma Annotate test_subtypes.adb:7:4: use of pragma Annotate Ok, this somehow works. Now - of course - I do not want to swap one coding standard violation (predefined numeric types) with two different ones (forbidden pragma), so I want allow the "Annotate" pragma: $ gnatcheck src/test_subtypes.adb -rules +RPredefined_Numeric_Types +RForbidden_Pragmas:ALL -RForbidden_Pragmas:Annotate test_subtypes.adb:3:4: use of pragma Suppress test_subtypes.adb:5:4: use of pragma Annotate test_subtypes.adb:7:4: use of pragma Annotate What...? Although I stated that "Annotate" is allowed, the rule is still violated? Interestingly, for "pragma Suppress" the above works, if I say "-RForbidden_Pragmas:Annotate,Suppress" the "Suppress" pragma does not get flagged anymore, but the two "Annotate" pragmas still do get flagged. So I suppose I read the gnatcheck manual correctly and it's not just some stupid syntactic error on my side. Is that intended behaviour of gnatcheck or am I doing something fundamentally wrong? For now, I will probably reverse the logic for pragma usage by explicitely listing all that are disallowed (my intent was to disallow all and turn off the check explicitely for those allowed), but especially for implementation defined pragmas this is not really a good solution, because I can not know them in advance. And of course, for each justified coding standard violation I now get two different ones into the report, and somehow I doubt, I could convince the Important People(tm) that this is better than not justifying the rule violation at all. Vinzent. -- f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.