summaryrefslogtreecommitdiff
path: root/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-05-26 15:08:11 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-05-26 15:23:25 -0700
commita9159f9e87b518ba0a4ad43db8fdd58a678b3a92 (patch)
treede5399a37e66a5837857dd1a03ad71aa0f5dec48 /ast_to_hir.cpp
parentfd55da21471fbab7e78c12a31b4eba0d33481735 (diff)
Fix setting the maximum accessed array element
Array dereferences now point to variable dereferences instead of pointing directly to variables. This necessitated some changes to the way the variable is accessed when setting the maximum index array element.
Diffstat (limited to 'ast_to_hir.cpp')
-rw-r--r--ast_to_hir.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index 64f8ef4..7759c36 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -1097,7 +1097,7 @@ ast_expression::hir(exec_list *instructions,
error_emitted = op[0]->type->is_error() || op[1]->type->is_error();
- ir_instruction *const array = op[0];
+ ir_rvalue *const array = op[0];
result = new ir_dereference_array(op[0], op[1]);
@@ -1181,7 +1181,13 @@ ast_expression::hir(exec_list *instructions,
}
if (array->type->is_array()) {
- ir_variable *const v = array->as_variable();
+ /* If the array is a variable dereference, it dereferences the
+ * whole array, by definition. Use this to get the variable.
+ *
+ * FINISHME: Should some methods for getting / setting / testing
+ * FINISHME: array access limits be added to ir_dereference?
+ */
+ ir_variable *const v = array->whole_variable_referenced();
if ((v != NULL) && (unsigned(idx) > v->max_array_access))
v->max_array_access = idx;
}