* GNAT.Source_Info Volatile and SPARK
@ 2023-12-08 18:28 Kevin Chadwick
2023-12-09 14:16 ` Kevin Chadwick
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Chadwick @ 2023-12-08 18:28 UTC (permalink / raw)
I guess the SPARK annotations in GNAT.Source_Info mark them as
Volatile_Functions for good reason.
I'm not sure how to handle using them in SPARK. They produce compile time
known constants but I guess SPARK does not know e.g. the String length.
I use them in a logging function which is everywhere. So I get error
Volatile function call as actual is not allowed in SPARK when calling
GNAT.Source_Info.Source_Location as a loggers parameter. Perhaps I should
just avoid using them for SPARK compatibility? I can get by with
GNAT.Source_Info.Line which only produces warnings and not the above error
but it is not ideal.
I can use the function File as a package global constant. Any other ideas?
--
Regards, Kc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: GNAT.Source_Info Volatile and SPARK
2023-12-08 18:28 GNAT.Source_Info Volatile and SPARK Kevin Chadwick
@ 2023-12-09 14:16 ` Kevin Chadwick
2023-12-09 14:33 ` Kevin Chadwick
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Chadwick @ 2023-12-09 14:16 UTC (permalink / raw)
>I can use the function File as a package global constant. Any other ideas?
I shall go with doing the above per package for Gnat.Source_Info.File and
wrapping the Gnat.Source_Info.Line procedure with one marked with Global =>
null.
Where would I suggest that Global => null be added to Line?
--
Regards, Kc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: GNAT.Source_Info Volatile and SPARK
2023-12-09 14:16 ` Kevin Chadwick
@ 2023-12-09 14:33 ` Kevin Chadwick
2023-12-09 14:57 ` Jeffrey R.Carter
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Chadwick @ 2023-12-09 14:33 UTC (permalink / raw)
On 09/12/2023 14:16, Kevin Chadwick wrote:
>>I can use the function File as a package global constant. Any other ideas?
>
>I shall go with doing the above per package for Gnat.Source_Info.File and
> wrapping the Gnat.Source_Info.Line procedure with one marked with Global =>
> null.
>
>Where would I suggest that Global => null be added to Line?
Doh...Of course I can't wrap Line, ha ha. If I want the right line.
--
Regards, Kc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: GNAT.Source_Info Volatile and SPARK
2023-12-09 14:33 ` Kevin Chadwick
@ 2023-12-09 14:57 ` Jeffrey R.Carter
2023-12-09 15:13 ` Kevin Chadwick
0 siblings, 1 reply; 5+ messages in thread
From: Jeffrey R.Carter @ 2023-12-09 14:57 UTC (permalink / raw)
On 2023-12-09 15:33, Kevin Chadwick wrote:
> On 09/12/2023 14:16, Kevin Chadwick wrote:
>>
>> I shall go with doing the above per package for Gnat.Source_Info.File and
>> wrapping the Gnat.Source_Info.Line procedure with one marked with Global =>
>> null.
>
> Doh...Of course I can't wrap Line, ha ha. If I want the right line.
Perhaps
private with Gnat.Source_Info;
package Source_Line_Info with SPARK_Mode is
function Line ... with Global => null;
private -- Source_Line_Info
pragma SPARK_Mode (Off);
function Line ... renames Gnat.Source_Info.line;
end Source_Line_Info;
(Untested)
--
Jeff Carter
"Unix and C are the ultimate computer viruses."
Richard Gabriel
99
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: GNAT.Source_Info Volatile and SPARK
2023-12-09 14:57 ` Jeffrey R.Carter
@ 2023-12-09 15:13 ` Kevin Chadwick
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Chadwick @ 2023-12-09 15:13 UTC (permalink / raw)
\r>> Doh...Of course I can't wrap Line, ha ha. If I want the right line.
>
>Perhaps
>
>private with Gnat.Source_Info;
>
>package Source_Line_Info with SPARK_Mode is
> function Line ... with Global => null;
>private -- Source_Line_Info
> pragma SPARK_Mode (Off);
>
> function Line ... renames Gnat.Source_Info.line;
>end Source_Line_Info;
>
>(Untested)
Interesting, Thanks. I might just use random identifiers. With the added
benefit of knowing it will work with any runtime, any platform and any
compilation options.
--
Regards, Kc
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-09 15:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08 18:28 GNAT.Source_Info Volatile and SPARK Kevin Chadwick
2023-12-09 14:16 ` Kevin Chadwick
2023-12-09 14:33 ` Kevin Chadwick
2023-12-09 14:57 ` Jeffrey R.Carter
2023-12-09 15:13 ` Kevin Chadwick
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox