DEVELOPMENT EDITION · 769442725406
Language Reference
On this page

Aspects, pragmas, and representation controls

An aspect attaches a property or contract to a declaration. A pragma appears in a permitted context, declarative region, or statement sequence. Syntax recognition, placement legality, effect, and proof of the property are separate matters. This chapter catalogs every aspect and pragma name Verada recognizes and what each does.

Vada normally writes with Name => Value on a declaration. Varc annotations and contract clauses, and Vibe selected helpers/decorators, map supported properties to the same model. Their syntax references state the actual spellings; there is no generic promise that any recognized Ada aspect can be expressed by an arbitrary Python decorator.

Effective contract and analysis aspects

Aspect Placement and implemented role
Pre Subprogram/callback accepted profile; caller obligation and body entry assumption
Post Subprogram/callback accepted profile; normal-return property
Global Subprogram effects over visible variables/abstract state; required on imports
Depends Permitted output dependencies on inputs and prior state
Contract_Cases Guarded normal outcomes with partition obligations
Ghost Objects, types, subprograms and packages used only for proof; they cannot affect executable results and are erased from compiled code
Always_Terminates The procedure must terminate, which is proved
Subprogram_Variant Increasing/decreasing recursive progress components
Type_Invariant Private abstraction's full view; valid input/output boundary property
Default_Initial_Condition Property a default-initialized object of a private type has
Static_Predicate Subtype predicate restricted to static expressions, checked where a value enters the subtype
Dynamic_Predicate Subtype predicate checked wherever a value enters the subtype
Predicate Recognized predicate form routed through subtype predicate checking
Ghost_Predicate A dynamic predicate that may name ghost entities; a membership test of the subtype is then ghost code, allowed only in contracts, assertions and ghost code (B3013)
Initializes Package state established during elaboration
Abstract_State Public names for hidden package state, including external state
Part_Of A constituent's relationship to abstract state
Refined_Global On a body: its effects in terms of the state's constituents
Refined_Depends On a body: its dependencies in terms of the state's constituents
Refined_State Mapping of abstract state to body constituents
Relaxed_Initialization The object may be partly initialized; 'Initialized tracks which parts are, and reads of unset parts are still errors
Exceptional_Cases Which user exceptions a procedure may propagate, and what holds when it does; functions cannot propagate exceptions

Only Pre'Class and Post'Class are accepted class-wide aspects. Other class-wide spellings are excluded. Contracts gives the meaning, type checking, and boundary placement of these properties; writing an aspect is not itself discharging it.

Resource and container protocols

Aspect Implemented role and requirements
Finalizable Registers conforming Finalize and optional Adjust, with Relaxed_Finalization True; limited/copyable rules and termination apply
Iterable Resolves First/Next/Has_Element/Element protocol operations of the required profiles
Aggregate Resolves Empty and Add_Unnamed, so that [...] builds the container

Protocols are resolved with the relevant package declarations visible. A misspelled member, wrong profile, unsupported combination, or invalid lifecycle is an error, not a request for reflective runtime lookup. See composite types and ownership.

Default values

Aspect Implemented role and requirements
Default_Value On a scalar type: a static value of the type, within its first subtype, that every object, record component and allocator of the type (or of a type derived from it) made without a value takes; checked against a narrower subtype where an object of one takes it
Default_Component_Value On an array type whose components are scalar: a static value of the component type that every component of an object of the array type made without a value takes

Flow analysis counts such objects as initialized, and the prover and the compiled code both start them with the default. Either aspect on a subtype, on a type of another kind, or with a value that is not static is an error. A private type whose full view has Default_Value gives it to the objects of the private type declared outside the package too.

Imports, exports, and external state

Aspect Implemented role and limits
Import External subprogram/object handling; an imported address-bearing object is not initialized normally
Export Makes a subprogram or package object visible to foreign code
Convention Ada or C calling convention; on a type, Ada, C or C_Pass_By_Copy (any other, Fortran say, is B0501)
External_Name The foreign symbol name of an import or export
Address Package-level effectively volatile object at an accepted address expression
Volatile External-object semantics and actual volatile reads/writes
Atomic Classifies the object as volatile, as Volatile does; there are no atomic read-modify-write operations
Volatile_Components, Atomic_Components On an array type or object: each component is volatile (or atomic), so the object is effectively volatile, and each component is read and written where the program says
No_Caching A volatile variable with none of the four external properties unless given: flow analysis treats it as an ordinary variable, and the code still reads and writes it every time
Async_Readers Environment can observe writes
Async_Writers Environment can change the value between reads
Effective_Reads Reads themselves are observable effects
Effective_Writes Writes themselves are observable effects
Volatile_Function A function that may read volatile state; called only as a whole value
Elaborate_Body Package body/elaboration relationship read by the driver
Initial_Condition Proved where the package's elaboration ends, and known to the main program (B5110)
Refined_Post On a body: a further postcondition over what the body sees, proved with the declaration's
Constant_After_Elaboration Only elaboration may change the variable; a subprogram that may is B3024
Extensions_Visible Verada always makes a tagged parameter's extension visible; => False is rejected (B0501)
Side_Effects A function that may write globals and parameters, raise and not terminate; called only as an assignment's or a declaration's whole value (B2029)
Program_Exit The subprogram may exit the whole program (GNAT.OS_Lib.OS_Exit), and its condition holds when it does; a call that may exit is allowed only where the caller may too (B5120)
Exit_Cases How the subprogram ends (Normal_Return, Exception_Raised, (Exception_Raised => E), Program_Exit) by guards on entry, proved at every end (B5121)

An explicit address and accurate effects do not prove a hardware register exists or a foreign routine obeys its contract. Concurrency and devices and the Toolchain foreign-interface chapter state the environmental obligations.

A type declared Volatile, Atomic, Volatile_Components or Atomic_Components makes each of its objects effectively volatile, as the aspect on the object would.

Max_Queue_Length => N, on a protected entry, bounds the callers that may wait on it: flow analysis checks that the tasks (and the main subprogram) that may call the entry are at most N (B3030).

Priority is additionally consumed by the task/protected frontend before ordinary aspect checking. It applies to tasks and protected objects only. Verada checks ceilings with it; the runtime does not schedule tasks by priority (see concurrency).

Names accepted for Ada compatibility

The following names are accepted so that Ada sources compile unchanged. They do not change what the program computes or what Verada proves:

Name Effect in Verada
Inline None; the code generator chooses what to inline
Pure, Preelaborate None; Verada computes the elaboration order and checks initialization itself
No_Return None; flow analysis and proof follow every path through the called subprogram
Size, Object_Size, Component_Size, Alignment, Pack, Independent, Independent_Components None; Verada chooses the representation of every type, and every component is independently addressable
Bit_Order, Scalar_Storage_Order, Universal_Aliasing None; Verada chooses the representation of every type, and converts bits only between scalars of one size
Inline_Always None, as Inline
Discard_Names None; 'Image of an enumeration value is its name
Linker_Section None; the code generator places every object
Link_Name None; set a foreign symbol with External_Name
Annotate Verada's own annotations are written (Verada, Kind, ...): At_End_Borrow and Mutable_In_Parameters (ownership), Inline_For_Proof, Hide_Info, Unhide_Info and Logical_Equal (proof operations), Enclave (enclaves), and False_Positive and Intentional (B8009). GNATprove is accepted in place of Verada for code written for GNATprove; any other annotation is metadata for other tools and has no effect
Unreferenced Suppresses the warnings for an object that is never read (B3025)

SPARK_Mode => On changes nothing, and SPARK_Mode => Off is reported with warning B8004: Verada analyses the whole program regardless. The pragma, pragma SPARK_Mode (Off);, is reported the same way wherever it stands: as a configuration pragma, a declaration or a statement.

Verada_Object_Type is internal: Verada gives it to the packages that task and protected types become. Programs do not write it.

Statement pragmas

Pragma Role
Assert(Boolean) Prove/execute the applicable assertion at that point
Assume(Boolean) Trust the hypothesis and report B8002; it is not proved
Loop_Invariant(Boolean) Condition at the annotated point directly inside a loop
Loop_Variant(Increases/Decreases => ...) Loop progress measure, proved to change at each iteration
Annotate (Verada, False_Positive | Intentional, "pattern", "reason") Justifies the unproved check of the statement before it whose message matches the pattern (B8009); the check stays in the code
Annotate of another kind, Warnings, SPARK_Mode, Debug, Inspection_Point Accepted; no effect

Other statement pragmas are reported as unknown and ignored with B8001. A name recognized as a declaration pragma is not automatically effective as a statement pragma.

Declaration and context pragmas

At declaration level, SPARK_Mode, Annotate, Warnings, Assertion_Policy, Elaborate, Elaborate_All, Unreferenced, Suppress, Unsuppress, Restrictions, Profile, Ada_2022, and Ada_2012 are recognized compatibility forms. The declaration checker does not implement arbitrary policy changes from those names. In particular Suppress and Assertion_Policy do not provide an alternative to the documented command proof modes. Use effective aspects for the implemented state/elaboration requirements.

The historical declaration pragmas below are obsolescent: each is warning B0902, with a fix that writes the aspect, and takes the aspect's effect on the declaration it names in the same declarative part (or, naming nothing, on the package):

Historical pragma names Modern direction
Inline, No_Return, Pack The corresponding aspect (no effect, as above)
Import, Interface, Export, Convention Import/Export/Convention/External_Name aspects
Pure, Preelaborate, Elaborate_Body The corresponding package aspect
Precondition, Postcondition, Ghost, Type_Invariant Modern contract/ghost aspect forms
Atomic, Volatile, Independent The corresponding aspect
Atomic_Components, Volatile_Components The corresponding aspect
Unchecked_Union The aspect, which is not in Verada (B0501)

The aspects Unchecked_Union and Predicate_Failure are not in Verada (B0501). A variant of an unchecked union would be read without its discriminant, which no proof can check: keep the discriminant, or convert the bits between scalar types with Ada.Unchecked_Conversion. A predicate check is proved, so it never fails at run time: where a value comes from outside the program, test the predicate first (if X in S then).

The context pragma Extensions_Allowed (On) enables Vada's Verada extensions: iterator while clauses, lockstep sources, 'Scan and APL text. Other GNAT context pragmas, including Profile, are accepted without effect; naming a tasking profile does not make facilities outside Verada's tasking model available.

Representation clauses

A record representation clause, for R use record C at P range F .. L; ... end record;, and a record's Size (the aspect or for R'Size use N;) give the record's layout: each component is stored in the bits the clause names, counted from the low-order bit of storage unit P, and the record takes Size bits. That one layout is used for storage, 'Size, the representation attributes, Unchecked_Conversion and objects at an address, so a device register declared this way is read and written as its fields say, a field that does not fill whole bytes by reading the bytes that hold it and writing back the others unchanged. The clause is checked (B2031): every component named once, its bits static and enough for its subtype's values, a composite one on whole bytes, no two sharing bits unless in different variants, none beyond Size. A component the clause leaves out follows the last placed bit. A clause on a tagged type is B0501. An enumeration representation clause, for T use (A => 1, B => 4);, gives each literal the code memory holds for it, which 'Enum_Rep, 'Enum_Val and Unchecked_Conversion use too; it gives every literal one static code, increasing with the literals (B2032). Other attribute-definition clauses are accepted and do not change the layout Verada chooses. An address clause, for X'Address use ...;, places an external object exactly as the Address aspect does. The clauses for storage pools (Storage_Pool, and Storage_Size of an access type) and for stream attributes (Read, Write, Input, Output) are not in Verada (B0501); Storage_Size of a task type is accepted, and the run-time sizes the task's stack itself.

The obsolete for X use at Address form and record at mod form are diagnosed with B0904. Use a supported address aspect or a record representation clause.

Unknown aspect names produce B1013. A known name can still be misplaced or have an invalid value; each is diagnosed.