diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-14 17:57:20 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-14 17:57:20 +0000 |
commit | 894503cb3174b232a287581cfa2030139efce614 (patch) | |
tree | ddf0e0df1d4fea47c615b9a250b250f5f245cadb | |
parent | 39752c6b14932596939ae340e5da962f4263018a (diff) | |
download | gcc-894503cb3174b232a287581cfa2030139efce614.zip gcc-894503cb3174b232a287581cfa2030139efce614.tar.gz gcc-894503cb3174b232a287581cfa2030139efce614.tar.bz2 |
Correct protection against recursive types.
From-SVN: r167807
-rw-r--r-- | gcc/go/gofrontend/types.cc | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 8d440a8..98c4a97 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6795,14 +6795,10 @@ Named_type::do_get_tree(Gogo* gogo) break; case TYPE_FUNCTION: - // GENERIC can't handle a pointer to a function type whose - // return type is a pointer to the function type itself. It - // does into infinite loops when walking the types. - if (this->seen_ - && this->function_type()->results() != NULL - && this->function_type()->results()->size() == 1 - && (this->function_type()->results()->front().type()->forwarded() - == this)) + // Don't recur infinitely if a function type refers to itself. + // Ideally we would build a circular data structure here, but + // GENERIC can't handle them. + if (this->seen_) return ptr_type_node; this->seen_ = true; t = Type::get_named_type_tree(gogo, this->type_); @@ -6813,9 +6809,10 @@ Named_type::do_get_tree(Gogo* gogo) break; case TYPE_POINTER: - // GENERIC can't handle a pointer type which points to itself. - // It goes into infinite loops when walking the types. - if (this->seen_ && this->points_to()->forwarded() == this) + // Don't recur infinitely if a pointer type refers to itself. + // Ideally we would build a circular data structure here, but + // GENERIC can't handle them. + if (this->seen_) return ptr_type_node; this->seen_ = true; t = Type::get_named_type_tree(gogo, this->type_); |