# HG changeset patch # User Mario de Sousa # Date 1334585844 -3600 # Node ID f915ab676d7efe8d29381ca6fc9dcbc33297dbf3 # Parent b22ae67d80037169829cd103e69474814bc97aee Fixing check for assingment to FOR control variables. diff -r b22ae67d8003 -r f915ab676d7e stage3/lvalue_check.cc --- a/stage3/lvalue_check.cc Mon Apr 16 15:10:31 2012 +0100 +++ b/stage3/lvalue_check.cc Mon Apr 16 15:17:24 2012 +0100 @@ -75,9 +75,9 @@ /* No writing to iterator variables (used in FOR loops) inside the loop itself */ void lvalue_check_c::check_assignment_to_controlvar(symbol_c *lvalue) { for (unsigned int i = 0; i < control_variables.size(); i++) { - symbolic_variable_c *cvar = (symbolic_variable_c *)control_variables[i]; - if (strcasecmp(((identifier_c *)((symbolic_variable_c *)lvalue)->var_name)->value, ((identifier_c *)((symbolic_variable_c *)cvar)->var_name)->value) == 0) { - STAGE3_ERROR(0, lvalue, lvalue, "Assignment to FOR control variable are not be allowed."); + token_c *lvalue_name = get_var_name_c::get_name(lvalue); + if (compare_identifiers(lvalue_name, control_variables[i]) == 0) { + STAGE3_ERROR(0, lvalue, lvalue, "Assignment to FOR control variable is not allowed."); break; } } @@ -274,7 +274,7 @@ /* B 3.2.4 Iteration Statements */ /********************************/ void *lvalue_check_c::visit(for_statement_c *symbol) { - control_variables.push_back(symbol->control_variable); + control_variables.push_back(get_var_name_c::get_name(symbol->control_variable)); symbol->statement_list->accept(*this); control_variables.pop_back(); return NULL; diff -r b22ae67d8003 -r f915ab676d7e stage3/lvalue_check.hh --- a/stage3/lvalue_check.hh Mon Apr 16 15:10:31 2012 +0100 +++ b/stage3/lvalue_check.hh Mon Apr 16 15:17:24 2012 +0100 @@ -49,7 +49,7 @@ search_base_type_c search_base_type; int error_count; int current_display_error_level; - std::vector control_variables; + std::vector control_variables; void verify_is_lvalue (symbol_c *lvalue); void check_assignment_to_controlvar(symbol_c *lvalue);