diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-10-11 22:53:17 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-10-11 22:53:17 +0000 |
commit | 55e0ab1ad90b446e5fda024a35474a0b5a0ab386 (patch) | |
tree | 34dffec5bc928bd0f98e09d5dc441034f6eb6c68 /gcc/go | |
parent | b7d93b468a08d46d5bd7d0ed9e08695eef89ce24 (diff) | |
download | gcc-55e0ab1ad90b446e5fda024a35474a0b5a0ab386.zip gcc-55e0ab1ad90b446e5fda024a35474a0b5a0ab386.tar.gz gcc-55e0ab1ad90b446e5fda024a35474a0b5a0ab386.tar.bz2 |
compiler: Fix handling of hidden methods for unnamed types.
If an interface has hidden methods, we must make the interface
table comdat if it is for an unnamed type.
When we create a stub method for an unnamed type, don't make
it publically visible.
From-SVN: r203468
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/gogo-tree.cc | 9 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 6 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.h | 12 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 2 |
4 files changed, 23 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index fbc4652..ca80869 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -2154,10 +2154,11 @@ Gogo::interface_method_table_for_type(const Interface_type* interface, TREE_CONSTANT(decl) = 1; DECL_INITIAL(decl) = constructor; - // If the interface type has hidden methods, then this is the only - // definition of the table. Otherwise it is a comdat table which - // may be defined in multiple packages. - if (has_hidden_methods) + // If the interface type has hidden methods, and the table is for a + // named type, then this is the only definition of the table. + // Otherwise it is a comdat table which may be defined in multiple + // packages. + if (has_hidden_methods && type->named_type() != NULL) TREE_PUBLIC(decl) = 1; else { diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 0796caa..eebb753 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -3320,7 +3320,8 @@ Function::Function(Function_type* type, Function* enclosing, Block* block, closure_var_(NULL), block_(block), location_(location), labels_(), local_type_count_(0), descriptor_(NULL), fndecl_(NULL), defer_stack_(NULL), is_sink_(false), results_are_named_(false), nointerface_(false), - calls_recover_(false), is_recover_thunk_(false), has_recover_thunk_(false), + is_unnamed_type_stub_method_(false), calls_recover_(false), + is_recover_thunk_(false), has_recover_thunk_(false), in_unique_section_(false) { } @@ -3844,7 +3845,8 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) else if (!Gogo::is_hidden_name(no->name()) || this->type_->is_method()) { - is_visible = true; + if (!this->is_unnamed_type_stub_method_) + is_visible = true; std::string pkgpath = gogo->pkgpath_symbol(); if (this->type_->is_method() && Gogo::is_hidden_name(no->name()) diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 8c4ccf9..31b258d 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -953,6 +953,15 @@ class Function this->nointerface_ = true; } + // Record that this function is a stub method created for an unnamed + // type. + void + set_is_unnamed_type_stub_method() + { + go_assert(this->is_method()); + this->is_unnamed_type_stub_method_ = true; + } + // Add a new field to the closure variable. void add_closure_field(Named_object* var, Location loc) @@ -1178,6 +1187,9 @@ class Function bool results_are_named_ : 1; // True if this method should not be included in the type descriptor. bool nointerface_ : 1; + // True if this function is a stub method created for an unnamed + // type. + bool is_unnamed_type_stub_method_ : 1; // True if this function calls the predeclared recover function. bool calls_recover_ : 1; // True if this a thunk built for a function which calls recover. diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index f73ca7a..69e3e99 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -9031,6 +9031,8 @@ Type::build_stub_methods(Gogo* gogo, const Type* type, const Methods* methods, fntype->is_varargs(), location); gogo->finish_function(fntype->location()); + if (type->named_type() == NULL && stub->is_function()) + stub->func_value()->set_is_unnamed_type_stub_method(); if (m->nointerface() && stub->is_function()) stub->func_value()->set_nointerface(); } |