comp.lang.ada
 help / color / mirror / Atom feed
* Minor SPARK problem concerning 'redundant' with clauses.
@ 2009-06-10 19:31 xorquewasp
  2009-06-10 20:11 ` sjw
  2009-06-10 20:55 ` britt.snodgrass
  0 siblings, 2 replies; 5+ messages in thread
From: xorquewasp @ 2009-06-10 19:31 UTC (permalink / raw)


I have a package P1 that uses the value of a constant defined in P2.

SPARK requires me to --# inherit P2 and the only place the annotation
can appear is in the spec of P1. The Ada compiler, however, sees that
the constant is only referenced in the body and complains loudly that
the 'with' clause is redundant and might be moved into the body of P2.

Is there a sensible solution to stop the two systems treading on each
other like this? In most cases, I can hack around the problem with a
spurious 'use type' clause (as much as I dislike it).

I tried to use pragma Warnings (Off) to wrap the "redundant" with
clauses, but of course SPARK immediately rejected it:

***        Syntax Error      : No complete PRAGMA_REP can be followed
by
           reserved word "WITH" here.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minor SPARK problem concerning 'redundant' with clauses.
  2009-06-10 19:31 Minor SPARK problem concerning 'redundant' with clauses xorquewasp
@ 2009-06-10 20:11 ` sjw
  2009-06-10 20:55 ` britt.snodgrass
  1 sibling, 0 replies; 5+ messages in thread
From: sjw @ 2009-06-10 20:11 UTC (permalink / raw)


On Jun 10, 8:31 pm, xorquew...@googlemail.com wrote:
> I have a package P1 that uses the value of a constant defined in P2.
>
> SPARK requires me to --# inherit P2 and the only place the annotation
> can appear is in the spec of P1. The Ada compiler, however, sees that
> the constant is only referenced in the body and complains loudly that
> the 'with' clause is redundant and might be moved into the body of P2.
>
> Is there a sensible solution to stop the two systems treading on each
> other like this? In most cases, I can hack around the problem with a
> spurious 'use type' clause (as much as I dislike it).

You could explore the options available with -gnatw, perhaps? None
look appropriate at first glance, but ..



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minor SPARK problem concerning 'redundant' with clauses.
  2009-06-10 19:31 Minor SPARK problem concerning 'redundant' with clauses xorquewasp
  2009-06-10 20:11 ` sjw
@ 2009-06-10 20:55 ` britt.snodgrass
  2009-06-11  8:45   ` xorque
  2009-06-11  8:52   ` Robin Messer
  1 sibling, 2 replies; 5+ messages in thread
From: britt.snodgrass @ 2009-06-10 20:55 UTC (permalink / raw)


I'm getting a bit rusty with my SPARK, but I think the with clause can
be moved to the package body (only the body) while the inherit
annotation remains in the package spec.  We always build with the -
gnatwa switch to enable all optional warnings and I think this warning
was easy to fix by moving the "with" to the body.

- Britt



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minor SPARK problem concerning 'redundant' with clauses.
  2009-06-10 20:55 ` britt.snodgrass
@ 2009-06-11  8:45   ` xorque
  2009-06-11  8:52   ` Robin Messer
  1 sibling, 0 replies; 5+ messages in thread
From: xorque @ 2009-06-11  8:45 UTC (permalink / raw)


On Jun 10, 9:55 pm, britt.snodgr...@gmail.com wrote:
> I'm getting a bit rusty with my SPARK, but I think the with clause can
> be moved to the package body (only the body) while the inherit
> annotation remains in the package spec.  We always build with the -
> gnatwa switch to enable all optional warnings and I think this warning
> was easy to fix by moving the "with" to the body.

I see, thanks. I wasn't aware that 'with' and 'inherit' could be
distinct like that.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Minor SPARK problem concerning 'redundant' with clauses.
  2009-06-10 20:55 ` britt.snodgrass
  2009-06-11  8:45   ` xorque
@ 2009-06-11  8:52   ` Robin Messer
  1 sibling, 0 replies; 5+ messages in thread
From: Robin Messer @ 2009-06-11  8:52 UTC (permalink / raw)


Britt is right. The correct solution is to move the "with" to the
package
body. As an aside, the SPARK Examiner recognises certain pragmas, but
in
the majority of cases it just issues a warning and continues its
analysis.
It is, however, a bit more fussy about where pragmas can be placed.
The following code is accepted by the Examiner (with a warning about
the
pragma).

pragma Warnings (Off);
with Q;
--# inherit Q;
package P
is
      type T is range 0 .. 100;
end P;

--
Robin



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-11  8:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10 19:31 Minor SPARK problem concerning 'redundant' with clauses xorquewasp
2009-06-10 20:11 ` sjw
2009-06-10 20:55 ` britt.snodgrass
2009-06-11  8:45   ` xorque
2009-06-11  8:52   ` Robin Messer

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