From 65ad556f3df2f9dc967eda110579e6c355f06102 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 20 Nov 2013 13:57:40 +0100 Subject: Another name resolution bugfix for generate blocks --- frontends/ast/simplify.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'frontends') diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 6d662c8f..636dde48 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -383,7 +383,10 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, } assert(children[1]->type == AST_IDENTIFIER); newNode = children[1]->clone(); - newNode->str = stringf("%s[%d].%s", str.c_str(), children[0]->integer, children[1]->str.c_str()); + const char *second_part = children[1]->str.c_str(); + if (second_part[0] == '\\') + second_part++; + newNode->str = stringf("%s[%d].%s", str.c_str(), children[0]->integer, second_part); goto apply_newNode; } @@ -599,8 +602,10 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, buf->expand_genblock(varbuf->str, sstr.str(), name_map); if (type == AST_GENFOR) { - for (size_t i = 0; i < buf->children.size(); i++) + for (size_t i = 0; i < buf->children.size(); i++) { + buf->children[i]->simplify(false, false, false, stage, -1, false); current_ast_mod->children.push_back(buf->children[i]); + } } else { for (size_t i = 0; i < buf->children.size(); i++) current_block->children.insert(current_block->children.begin() + current_block_idx++, buf->children[i]); @@ -633,8 +638,10 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, expand_genblock(std::string(), str + ".", name_map); } - for (size_t i = 0; i < children.size(); i++) + for (size_t i = 0; i < children.size(); i++) { + children[i]->simplify(false, false, false, stage, -1, false); current_ast_mod->children.push_back(children[i]); + } children.clear(); did_something = true; @@ -668,8 +675,10 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, buf->expand_genblock(std::string(), buf->str + ".", name_map); } - for (size_t i = 0; i < buf->children.size(); i++) + for (size_t i = 0; i < buf->children.size(); i++) { + buf->children[i]->simplify(false, false, false, stage, -1, false); current_ast_mod->children.push_back(buf->children[i]); + } buf->children.clear(); delete buf; -- cgit v1.2.3