comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: [AdaControl] Limiting where objects of a specific type can be declared
Date: Tue, 14 Mar 2017 14:47:49 +0100
Date: 2017-03-14T14:47:49+01:00	[thread overview]
Message-ID: <oa8s4r$1ig$1@dont-email.me> (raw)
In-Reply-To: <87varcq9e3.fsf@adaheads.consafe1.org>

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

      reply	other threads:[~2017-03-14 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14 13:24 [AdaControl] Limiting where objects of a specific type can be declared Jacob Sparre Andersen
2017-03-14 13:47 ` J-P. Rosen [this message]
replies disabled

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