How do I instantiate a non-library-level package in SPARK Ada?
Say I have something like:
subtype Die is Integer range 1..6;
package Random_Die
is
new Ada.Numerics.Discrete_Random(Die);
That gives me the errors:
instantiation error at a-nudira.ads.45
incorrect placement of "Spark_Mode"
Random_Die is not a libray level package
Presumably I need to turn SPARK_Mode off for Ada.Numerics.Discrete_Random, but I can't work out the right place to put the pragma.
Generics are only checked by SPARK when they are instantiated. :-(
The error message looks like you have attempted to put a SPARK_Mode aspect somewhere inside the generic. That will not work. You should put the
SPARK_Mode => On
aspect on the unit instantiating the generic package.