Skip to content

Pragma Placement

Benjamin Kowarsch edited this page Jun 25, 2026 · 13 revisions

Terminology

Pragma Block

The largest unit of composition for pragmas is the pragma block. A pragma block consists of an opening and closing delimiter and a pragma body.

pragmaBlock := '<*' pragmaBody '*>' ;

The length of a pragma block including delimiters, line breaks and NUL termination shall not exceed a buffer size of 1024 octets.

Pragma Body

The pragma body consists of one or more pragma clauses. There are three categories: standalone clauses, combinable clauses and implementation defined clauses.

pragmaBody := standalonePragmaClause | pragmaClauseSeq | implDefPragmaClause ;

Pragma Clause

A pragma clause is the smallest unit of composition for pragmas. It consists of one or more tokens that encode the pragma's semantic information.

Pragma Grouping

Standalone Pragmas

A pragma clause that may not be placed together with other clauses in a single pragma block is called a standalone pragma clause. Standalone pragma clauses are:

ENCODING, ENDFWD, FORWARD, GENERATED, MSG, PRESETS, TELL, TICKET, UNSET and VARIANT.

Multi-Clause Pragmas

A pragma clause that may be placed together with other clauses in a single pragma block is called a combinable pragma clause. Combinable pragma clauses are:

ABI, ADDR, ALIGN, ARC, BORROWER, CONTIGUOUS, DEPRECATED, DETM, FFI, FFIDENT, GC, IN, INLINE, LEADBITS, LOWLATENCY, MEMALIGN, NOINLINE, NORETURN, OUT, OWNER, PACKED, PADBITS, PRIVATETO, PURE, RELEASE, RESIDENT, RETAIN, SINGLEASSIGN, VOLATILE and WEAK.

Adjacent Pragma Blocks

A pragma block may be followed by one or more adjacent pragma blocks.

Pragma Placement By Scope

File Scope

Pragmas with file scope may be placed strictly in order

(1) ENCODING, (2) VARIANT, (3) GENERATED

possibly before or after a comment, but always before the module header.

Module Scope

Pragmas with module scope may be placed at the end of the module header of a top-level module before the terminating semicolon. Pragmas must not be placed in the header of any local module.

Constant Scope

Pragmas with constant scope may be placed at the end of a constant definition before the terminating semicolon.

Variable Scope

Pragmas with variable scope may be placed at the end of a variable definition before the terminating semicolon.

Array Scope

Pragmas with array scope may be placed at the end of an array type definition before the terminating semicolon.

Record Scope

Pragmas with record scope may be placed at the end of a record type definition's header before the field list sequence.

Field List Scope

Pragmas with field list scope may be placed at the end of a record field list before the separating semicolon, or the record's terminating END.

Field List Item Scope

Pragmas with field list item scope may be placed after a field's identifier before a separating comma, or the identifier list's terminating colon.

Procedure Type Scope

Pragmas with procedure type scope may be placed at the end of a procedure type definition before the terminating semicolon.

Formal Type List Scope

Pragmas with formal type list scope may be placed at the end of a formal type list before the separating semicolon or the terminating closing parenthesis.

Formal Type List Item Scope

Pragmas with formal type list item scope may be placed after a formal type's identifier before a separating comma or the formal type list's terminating closing parenthesis.

Other Type Scope

Pragmas with any other type scope may be placed at the end of the type definition before the terminating semicolon.

Procedure Scope

Pragmas with procedure scope may be placed at the end of a procedure header before the terminating semicolon.

Parameter List Scope

Pragmas with parameter list scope may be placed at the end of a formal parameter list before the separating semicolon or the terminating closing parenthesis.

Parameter List Item Scope

Pragmas with parameter list item scope may be placed after a parameter's identifier before a separating comma or the parameter list's terminating closing parenthesis.

Point-Forward Scope

Pragmas with point-forward scope may be placed anywhere within the module body where an import, a declaration or definition, a statement or a comment may appear

No Scope

Pragmas without scope may be placed anywhere within a source file, after any and all pragmas with file scope, anywhere an import, a declaration or definition, a statement or a comment may appear.

Mutual Exclusion

Scope Exclusion

No pragma may be placed in a list scope where a pragma has been placed in list item scope.

TYPE Foo = RECORD
  a, b : Bar <*ALIGN=2*> ; (* valid *)
  c <*ALIGN=2*>, d : Baz;  (* valid *)
  e <*PADBITS=2*>, f : Bam <*ALIGN=2*> (* invalid *)
END; (* Foo *)

Logical Exclusion

The following pragmas are mutually exclusive when applied to the same scope or overlapping scope: