From ce3c3cbb580752f0aecc905db84c8e4836eb2cf2 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 29 Feb 2012 22:43:15 +0000 Subject: [PATCH] compiler: Fix handling of invalid types within invalid types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184674 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/types.cc | 24 +++++------------------- gcc/go/gofrontend/types.h | 3 ++- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index a2064bb..6abe21d 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -4116,7 +4116,6 @@ Struct_type::do_verify() Struct_field_list* fields = this->fields_; if (fields == NULL) return true; - bool ret = true; for (Struct_field_list::iterator p = fields->begin(); p != fields->end(); ++p) @@ -4126,7 +4125,6 @@ Struct_type::do_verify() { error_at(p->location(), "struct field type is incomplete"); p->set_type(Type::make_error_type()); - ret = false; } else if (p->is_anonymous()) { @@ -4134,19 +4132,17 @@ Struct_type::do_verify() { error_at(p->location(), "embedded type may not be a pointer"); p->set_type(Type::make_error_type()); - return false; } - if (t->points_to() != NULL - && t->points_to()->interface_type() != NULL) + else if (t->points_to() != NULL + && t->points_to()->interface_type() != NULL) { error_at(p->location(), "embedded type may not be pointer to interface"); p->set_type(Type::make_error_type()); - return false; } } } - return ret; + return true; } // Whether this contains a pointer. @@ -5206,10 +5202,7 @@ bool Array_type::do_verify() { if (!this->verify_length()) - { - this->length_ = Expression::make_error(this->length_->location()); - return false; - } + this->length_ = Expression::make_error(this->length_->location()); return true; } @@ -5899,10 +5892,7 @@ Map_type::do_verify() { // The runtime support uses "map[void]void". if (!this->key_type_->is_comparable() && !this->key_type_->is_void_type()) - { - error_at(this->location_, "invalid map key type"); - return false; - } + error_at(this->location_, "invalid map key type"); return true; } @@ -7885,7 +7875,6 @@ Named_type::do_verify() if (this->local_methods_ != NULL) { Struct_type* st = this->type_->struct_type(); - bool found_dup = false; if (st != NULL) { for (Bindings::const_declarations_iterator p = @@ -7899,12 +7888,9 @@ Named_type::do_verify() error_at(p->second->location(), "method %qs redeclares struct field name", Gogo::message_name(name).c_str()); - found_dup = true; } } } - if (found_dup) - return false; } return true; diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index 72c42eb..3fe8048 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -510,7 +510,8 @@ class Type // Verify the type. This is called after parsing, and verifies that // types are complete and meet the language requirements. This - // returns false if the type is invalid. + // returns false if the type is invalid and we should not continue + // traversing it. bool verify() { return this->do_verify(); } -- 2.7.4