aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-08-30 21:49:49 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-08-30 21:49:49 +0000
commit4a140826453da37a134d792e0224f4e37343e68a (patch)
tree04d27dc317f007c64a3954cd2744b89bc7ed0b47 /gcc
parentaff0632d4fa0d55b2c830e5dc975242dd246fc87 (diff)
downloadgcc-4a140826453da37a134d792e0224f4e37343e68a.zip
gcc-4a140826453da37a134d792e0224f4e37343e68a.tar.gz
gcc-4a140826453da37a134d792e0224f4e37343e68a.tar.bz2
compile, runtime: permit anonymous and empty fields in C header
Permit putting structs with anonymous and empty fields in the C header file runtime.inc that is used to build the C runtime code. This is required for upcoming 1.13 support, as the m struct has picked up an anonymous field. Doing this lets the C header contain all the type descriptor structs, so start using those in the C code. This cuts the number of copies of type descriptor definitions from 3 to 2. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192343 From-SVN: r275227
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/gogo.cc4
-rw-r--r--gcc/go/gofrontend/types.cc11
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;