Commit 7a6cb708 by Ian Lance Taylor

compiler: Check for initialization loop in constant initializer.

From-SVN: r184347
parent 061793a4
......@@ -834,8 +834,15 @@ Gogo::write_globals()
else if (init == NULL_TREE)
;
else if (TREE_CONSTANT(init))
this->backend()->global_variable_set_init(var,
tree_to_expr(init));
{
if (expression_requires(no->var_value()->init(), NULL, no))
error_at(no->location(),
"initialization expression for %qs depends "
"upon itself",
no->message_name().c_str());
this->backend()->global_variable_set_init(var,
tree_to_expr(init));
}
else if (is_sink)
var_init_tree = init;
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment