Commit 894503cb by Ian Lance Taylor

Correct protection against recursive types.

From-SVN: r167807
parent 39752c6b
...@@ -6795,14 +6795,10 @@ Named_type::do_get_tree(Gogo* gogo) ...@@ -6795,14 +6795,10 @@ Named_type::do_get_tree(Gogo* gogo)
break; break;
case TYPE_FUNCTION: case TYPE_FUNCTION:
// GENERIC can't handle a pointer to a function type whose // Don't recur infinitely if a function type refers to itself.
// return type is a pointer to the function type itself. It // Ideally we would build a circular data structure here, but
// does into infinite loops when walking the types. // GENERIC can't handle them.
if (this->seen_ if (this->seen_)
&& this->function_type()->results() != NULL
&& this->function_type()->results()->size() == 1
&& (this->function_type()->results()->front().type()->forwarded()
== this))
return ptr_type_node; return ptr_type_node;
this->seen_ = true; this->seen_ = true;
t = Type::get_named_type_tree(gogo, this->type_); t = Type::get_named_type_tree(gogo, this->type_);
...@@ -6813,9 +6809,10 @@ Named_type::do_get_tree(Gogo* gogo) ...@@ -6813,9 +6809,10 @@ Named_type::do_get_tree(Gogo* gogo)
break; break;
case TYPE_POINTER: case TYPE_POINTER:
// GENERIC can't handle a pointer type which points to itself. // Don't recur infinitely if a pointer type refers to itself.
// It goes into infinite loops when walking the types. // Ideally we would build a circular data structure here, but
if (this->seen_ && this->points_to()->forwarded() == this) // GENERIC can't handle them.
if (this->seen_)
return ptr_type_node; return ptr_type_node;
this->seen_ = true; this->seen_ = true;
t = Type::get_named_type_tree(gogo, this->type_); t = Type::get_named_type_tree(gogo, this->type_);
......
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