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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,6651f3800ba2b6ac X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news4.google.com!feeder.news-service.com!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Aspect programming Date: Thu, 28 Jul 2011 11:13:12 -0700 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 28 Jul 2011 18:13:10 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="JqHjgPp5xM1RSLdgY0ShBA"; logging-data="14754"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18C9IvH7GTPQNhtw5INFRNN" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 In-Reply-To: Cancel-Lock: sha1:EAIZaWceUih4n44u1EVPtyMABcE= Xref: g2news2.google.com comp.lang.ada:21374 Date: 2011-07-28T11:13:12-07:00 List-Id: On 7/27/2011 9:56 PM, AdaMagica wrote: > You're using GNAT, which requires one compilation unit per file. > Thus your pragma Assertion_Policy applies only to the unit where it is > in the context clause. > > If you want it to apply to all units, you have to use it as a > configuration pragma. I don't think this is entirely accurate. The RM says (10.1.5(8)) that configuration pragmas appear before the first compilation unit of a "compilation", and "The pragma applies to all compilation_units appearing in the compilation, unless there are none, in which case it applies to all future compilation_units compiled in the same environment." It's not clear which one applies in the original poster's case. If GNAT does disallow more than one compilation unit per file, then clearly the source in the original post must actually be multiple files (or else it wouldn't have worked), and we weren't really told where the dividing lines between the files are. For all we know, the first Assertion_Policy pragma could have been in its own file. But even if the first Assertion_Policy was in the same file as the Aspect_Programming_Test procedure, it's still a configuration pragma. The difference here is that it's a configuration pragma that applies only to Aspect_Programming_Test and not to any of the other compilation units (it appears that there's another Assertion_Policy that applies to the body of Stacks). But it's still a configuration pragma, so I think you really wanted to say something like "you have to use it as an environment-wide configuration pragma" or whatever the correct term is. Even so, I still don't think this is the right answer. Regarding preconditions, 6.1.1(20) says, "If the assertion policy in effect at the point of a subprogram or entry declaration is Check, then upon a call of the subprogram ... precondition checks are performed ...". So where is the subprogram declaration? Since Stacks is a generic, I think that the declarations of Int_Stacks.Push and Int_Stacks.Pop occur at the point the Stacks generic is instantiated, which where the instance Int_Stacks is declared, which is inside Aspect_Programming_Test; thus, even if the first Assertion_Policy is a configuration pragma that applies only to Aspect_Programming_Test, it still should apply here, and the precondition checks should be performed. However, I haven't researched all the relevant language rules carefully, and there may be some rules that affect when assertion policies apply to declarations (or Assert pragmas) created by instantiation. -- Adam