diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-16 02:24:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-16 02:24:10 +0000 |
commit | a2c76d48b566cbf71672ce4681b9b873d4dd9b13 (patch) | |
tree | 755fec1d83aaf38d3c0f5a0d34829f63e4f407c7 /gcc | |
parent | 7892de0c05ab87cf59da5b105b5470e6c6b0ef4f (diff) | |
download | gcc-a2c76d48b566cbf71672ce4681b9b873d4dd9b13.zip gcc-a2c76d48b566cbf71672ce4681b9b873d4dd9b13.tar.gz gcc-a2c76d48b566cbf71672ce4681b9b873d4dd9b13.tar.bz2 |
Rework handling of recursive function types.
From-SVN: r167898
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/types.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index bd0c7e5..af541e8 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6887,11 +6887,17 @@ Named_type::do_get_tree(Gogo* gogo) break; case TYPE_FUNCTION: - // 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. + // 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_) - return ptr_type_node; + { + Function_type* fntype = this->type_->function_type(); + if (fntype->results() != NULL + && fntype->results()->size() == 1 + && fntype->results()->front().type()->forwarded() == this) + return ptr_type_node; + } this->seen_ = true; t = Type::get_named_type_tree(gogo, this->type_); this->seen_ = false; |