117 if (NULL == dimension) |
129 if (NULL == dimension) |
118 return; |
130 return; |
119 |
131 |
120 /* Check lower limit */ |
132 /* Check lower limit */ |
121 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit)) |
133 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit)) |
122 if ( GET_CVALUE( int64, l->elements[i]) < GET_CVALUE( int64, dimension->lower_limit)) |
134 if ( GET_CVALUE( int64, l->elements[i]) < GET_CVALUE( int64, dimension->lower_limit) ) |
123 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
135 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
124 |
136 |
125 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit)) |
137 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit)) |
126 if ( GET_CVALUE( int64, l->elements[i]) < GET_CVALUE(uint64, dimension->lower_limit)) |
138 if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->lower_limit), GET_CVALUE( int64, l->elements[i])) > 0 ) |
127 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
139 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
128 |
140 |
129 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit)) |
141 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->lower_limit)) |
130 if ( GET_CVALUE(uint64, l->elements[i]) < GET_CVALUE(uint64, dimension->lower_limit)) |
142 if ( GET_CVALUE(uint64, l->elements[i]) < GET_CVALUE(uint64, dimension->lower_limit)) |
131 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
143 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
132 |
144 |
133 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit)) |
145 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->lower_limit)) |
134 if ( GET_CVALUE(uint64, l->elements[i]) < GET_CVALUE( int64, dimension->lower_limit)) |
146 if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->lower_limit)) < 0 ) |
135 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
147 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
136 |
148 |
137 /* Repeat the same check, now for upper limit */ |
149 /* Repeat the same check, now for upper limit */ |
138 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit)) |
150 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit)) |
139 if ( GET_CVALUE( int64, l->elements[i]) > GET_CVALUE( int64, dimension->upper_limit)) |
151 if ( GET_CVALUE( int64, l->elements[i]) > GET_CVALUE( int64, dimension->upper_limit)) |
140 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
152 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
141 |
153 |
142 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit)) |
154 if ( VALID_CVALUE( int64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit)) |
143 if ( GET_CVALUE( int64, l->elements[i]) > GET_CVALUE(uint64, dimension->upper_limit)) |
155 if ( cmp_unsigned_signed( GET_CVALUE(uint64, dimension->upper_limit), GET_CVALUE( int64, l->elements[i])) < 0 ) |
144 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
156 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
145 |
157 |
146 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit)) |
158 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE(uint64, dimension->upper_limit)) |
147 if ( GET_CVALUE(uint64, l->elements[i]) > GET_CVALUE(uint64, dimension->upper_limit)) |
159 if ( GET_CVALUE(uint64, l->elements[i]) > GET_CVALUE(uint64, dimension->upper_limit)) |
148 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
160 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
149 |
161 |
150 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit)) |
162 if ( VALID_CVALUE(uint64, l->elements[i]) && VALID_CVALUE( int64, dimension->upper_limit)) |
151 if ( GET_CVALUE(uint64, l->elements[i]) > GET_CVALUE( int64, dimension->upper_limit)) |
163 if ( cmp_unsigned_signed(GET_CVALUE(uint64, l->elements[i]), GET_CVALUE( int64, dimension->upper_limit)) < 0 ) |
152 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
164 {STAGE3_ERROR(0, symbol, symbol, "Array access out of bounds."); continue;} |
153 |
165 |
154 /* TODO: How do we make these comparisons between int and unsigned int, without the compiler complaining? */ |
|
155 } |
166 } |
156 } |
167 } |
157 |
168 |
158 |
169 |
159 |
170 |