DebugCheckArrayBounds¶
Checks at run time that the shapes in an array assignment conform.
Declaration¶
Syntax¶
DebugCheckArrayBounds(expr target, expr* components,
bool move_allocation)
Arguments¶
Argument |
Description |
|---|---|
|
the array being assigned to. |
|
the array operands of the right hand side, whose shapes must match |
|
|
Return values¶
None.
Description¶
This node is inserted by the array_op pass ahead of an array assignment when
bounds checking is enabled, and it is never produced by a frontend. It fails
at run time with a diagnostic naming the mismatching extents rather than
writing out of bounds.
Each element of components must itself be an array: the check compares the
extents of the target against the extents of the operands the assignment
reads.
Examples¶
(DebugCheckArrayBounds
:target (Var
:v (SymbolRef 1 "a")
)
:components [
(Var
:v (SymbolRef 1 "b")
)
]
:move_allocation false
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"a" (Variable
:parent_symtab 1
:name "a"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"b" (Variable
:parent_symtab 1
:name "b"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "main"
:dependencies []
:body [
(DebugCheckArrayBounds
:target (Var
:v (SymbolRef 1 "a")
)
:components [
(Var
:v (SymbolRef 1 "b")
)
]
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "a")
)
:value (Var
:v (SymbolRef 1 "b")
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)