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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: [AdaControl] Limiting where objects of a specific type can be declared Date: Tue, 14 Mar 2017 14:47:49 +0100 Organization: A noiseless patient Spider Message-ID: References: <87varcq9e3.fsf@adaheads.consafe1.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 14 Mar 2017 13:44:59 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="391ae88296c6e0795d738775bf02db5d"; logging-data="1616"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sT7jn1XjVVur8XTq0AKZK" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <87varcq9e3.fsf@adaheads.consafe1.org> Cancel-Lock: sha1:aHKrZkR4rW9/+nzCtO9oWPbvqu4= Xref: news.eternal-september.org comp.lang.ada:31709 Date: 2017-03-14T14:47:49+01:00 List-Id: Le 14/03/2017 à 14:24, Jacob Sparre Andersen a écrit : > The fast way to check for this with this AdaControl rule: > > check entities (local SQL.Statement_Type); > > > This looks good until AdaControl finds a clever programmer writing: > > procedure Something (...) is > Stmt : SQL.Statement_Type renames Global_Stmt; > begin > > Since this declaration doesn't leak memory, I don't want to stop the > programmer from using it. There is a subtility here: you are asking to check all local usages of type Statement_Type, which certainly applies here. What you /want/ is to check all local declarations of variables whose type is Statement_Type. Alternatively, you can use: check object_declarations (type, variable SQL.Statement_Type); but this will give you all variables of type Statement_Type, including the global ones. I take it as an enhancement suggestion to be able to specify a location for the above rule. Of course, it is always possible to disable the line. > The next interesting declaration AdaControl finds is a main program, > which declares a global variable for later use: > > procedure Main is > Stmt : SQL.Statement_Type; > begin > [...] > end Main; > > In this case the solution may simply be to ignore this group of utility > programs, when running AdaControl, but a modification to the rule would > be nice, as that would reduce the amount of thinking involved in > deciding which units to check and which not to check. Since there is nothing special to a main program in Ada, this is clearly a local usage... Disabling is probably the best thing to do. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr