array_extent_check¶
One comparison, made at run time by a DebugCheckArrayBounds, of the extents of two of its arrays in one dimension.
Declaration¶
Syntax¶
array_extent_check = (int left, int right, int dim, expr left_extent, expr right_extent)
Arguments¶
Argument |
Описание |
|---|---|
|
the first array: 0 for the |
|
the second array, an element of |
|
the dimension compared, starting at 1. |
|
the extent of |
|
the extent of |
Return values¶
None.
Описание¶
left is less than right, and dim is a dimension of both arrays. The
arrays are named by their positions so that a diagnostic can name and point at
them, while the extents are expressions of their own: an extent is
ArraySize of the array in that dimension, or, for an array constructor, the
size its type gives, since a constructor is not evaluated for its shape.
The check fails when the two extents differ. A comparison of target with an
operand reports a shape mismatch in the assignment, a comparison of two
operands one in a binary operation.
Examples¶
(array_extent_check
:left 0
:right 1
:dim 1
:left_extent (ArraySize
:v (Var
:v (SymbolRef 1 "a")
)
:dim (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
:right_extent (ArraySize
:v (Var
:v (SymbolRef 1 "b")
)
:dim (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
)
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
:memory_space :Global
)
: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 []
:common_block nil
)
"b" (Variable
:parent_symtab 1
:name "b"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Allocatable
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
:memory_space :Global
)
)
: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 []
:common_block nil
)
}
)
:name "main"
:dependencies []
:body [
(DebugCheckArrayBounds
:target (Var
:v (SymbolRef 1 "a")
)
:components [
(Var
:v (SymbolRef 1 "b")
)
]
:checks [
(array_extent_check
:left 0
:right 1
:dim 1
:left_extent (ArraySize
:v (Var
:v (SymbolRef 1 "a")
)
:dim (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
:right_extent (ArraySize
:v (Var
:v (SymbolRef 1 "b")
)
:dim (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
)
]
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "a")
)
:value (Var
:v (SymbolRef 1 "b")
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
]
:global_init nil
)
}
)
:items []
:global_init nil
)