diff options
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 4 | ||||
-rw-r--r-- | gcc/go/gofrontend/types.cc | 11 |
3 files changed, 12 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3ae07c4..e245973 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -db738935c77443840994e5a9f77e619e67a4c43a +11fd9208f8545e882f945d3ed86fcc33abf1a61b The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 7aec0cf..f8114ece 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -5238,11 +5238,11 @@ Gogo::write_c_header() // package they are mostly types defined by mkrsysinfo.sh based // on the C system header files. We don't need to translate // types to C and back to Go. But do accept the special cases - // _defer and _panic. + // _defer, _panic, and _type. std::string name = Gogo::unpack_hidden_name(no->name()); if (name[0] == '_' && (name[1] < 'A' || name[1] > 'Z') - && (name != "_defer" && name != "_panic")) + && (name != "_defer" && name != "_panic" && name != "_type")) continue; if (no->is_type() && no->type_value()->struct_type() != NULL) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 20f8f27..0ada841 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -6777,8 +6777,6 @@ Struct_type::can_write_to_c_header( p != fields->end(); ++p) { - if (p->is_anonymous()) - return false; if (!this->can_write_type_to_c_header(p->type(), requires, declare)) return false; if (Gogo::message_name(p->field_name()) == "_") @@ -6847,6 +6845,9 @@ Struct_type::can_write_type_to_c_header( } if (t->struct_type() != NULL) { + // We will accept empty struct fields, but not print them. + if (t->struct_type()->total_field_count() == 0) + return true; requires->push_back(no); return t->struct_type()->can_write_to_c_header(requires, declare); } @@ -6871,6 +6872,12 @@ Struct_type::write_to_c_header(std::ostream& os) const p != fields->end(); ++p) { + // Skip fields that are empty struct types. The C code can't + // refer to them anyhow. + if (p->type()->struct_type() != NULL + && p->type()->struct_type()->total_field_count() == 0) + continue; + os << '\t'; this->write_field_to_c_header(os, p->field_name(), p->type()); os << ';' << std::endl; |