From 38ac6be772b39c41aa4dee3446ed776084683d62 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 24 Dec 2010 00:33:49 +0000 Subject: [PATCH] Avoid endless loop checking whether type is pointer. From-SVN: r168221 --- gcc/go/gofrontend/types.cc | 13 +++++++++++++ gcc/go/gofrontend/types.h | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 2278c9426ff..6ea52971728 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6853,6 +6853,19 @@ Named_type::do_verify() return true; } +// Return whether this type is or contains a pointer. + +bool +Named_type::do_has_pointer() const +{ + if (this->seen_ > 0) + return false; + ++this->seen_; + bool ret = this->type_->has_pointer(); + --this->seen_; + return ret; +} + // Return a hash code. This is used for method lookup. We simply // hash on the name itself. diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index fea864a2e3b..cecf106e448 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -2552,8 +2552,7 @@ class Named_type : public Type do_verify(); bool - do_has_pointer() const - { return this->type_->has_pointer(); } + do_has_pointer() const; unsigned int do_hash_for_method(Gogo*) const; @@ -2677,7 +2676,7 @@ class Forward_declaration_type : public Type bool do_has_pointer() const - { return this->base()->has_pointer(); } + { return this->real_type()->has_pointer(); } unsigned int do_hash_for_method(Gogo* gogo) const