diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-02-15 19:34:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-02-15 19:34:33 +0000 |
commit | 72f812a2b53cc8b57c10534784022fea020be891 (patch) | |
tree | a28813ac3a48c065f8203dc9be27563ac3effb2c | |
parent | 1c4a5fc8caa525a85b92e737d86275a857fa2874 (diff) | |
download | gcc-72f812a2b53cc8b57c10534784022fea020be891.zip gcc-72f812a2b53cc8b57c10534784022fea020be891.tar.gz gcc-72f812a2b53cc8b57c10534784022fea020be891.tar.bz2 |
Don't crash lowering self-referential variable initializer.
From-SVN: r170194
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index e3c56b6..0be8c66 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -1139,7 +1139,8 @@ class Lower_parse_tree : public Traverse { public: Lower_parse_tree(Gogo* gogo, Named_object* function) - : Traverse(traverse_constants + : Traverse(traverse_variables + | traverse_constants | traverse_functions | traverse_statements | traverse_expressions), @@ -1147,6 +1148,9 @@ class Lower_parse_tree : public Traverse { } int + variable(Named_object*); + + int constant(Named_object*, bool); int @@ -1167,6 +1171,18 @@ class Lower_parse_tree : public Traverse int iota_value_; }; +// Lower variables. We handle variables specially to break loops in +// which a variable initialization expression refers to itself. The +// loop breaking is in lower_init_expression. + +int +Lower_parse_tree::variable(Named_object* no) +{ + if (no->is_variable()) + no->var_value()->lower_init_expression(this->gogo_, this->function_); + return TRAVERSE_CONTINUE; +} + // Lower constants. We handle constants specially so that we can set // the right value for the predeclared constant iota. This works in // conjunction with the way we lower Const_expression objects. |