aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2013-07-24 18:25:51 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-07-24 18:25:51 +0000
commitf1e18725591f12da43d0bb1a6ff93de9ee08b059 (patch)
tree1e8d7d89f596b2528c8896b9976241413c2fcade /gcc/go
parent08d22f9b41e46aba888e694f380e78d05c4321a2 (diff)
downloadgcc-f1e18725591f12da43d0bb1a6ff93de9ee08b059.zip
gcc-f1e18725591f12da43d0bb1a6ff93de9ee08b059.tar.gz
gcc-f1e18725591f12da43d0bb1a6ff93de9ee08b059.tar.bz2
go-gcc.cc (Gcc_backend::non_zero_size_type): If a struct has a fields...
* go-gcc.cc (Gcc_backend::non_zero_size_type): If a struct has a fields, recreate those fields with the first one with a non-zero size. From-SVN: r201222
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/ChangeLog6
-rw-r--r--gcc/go/go-gcc.cc49
2 files changed, 41 insertions, 14 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index ea82d35..db9d444 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,9 @@
+2013-07-24 Ian Lance Taylor <iant@google.com>
+
+ * go-gcc.cc (Gcc_backend::non_zero_size_type): If a struct has a
+ fields, recreate those fields with the first one with a non-zero
+ size.
+
2013-07-23 Ian Lance Taylor <iant@google.com>
* go-backend.c: Don't #include "rtl.h".
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index bd2d0dd..27c756e 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -1242,20 +1242,41 @@ Gcc_backend::non_zero_size_type(tree type)
switch (TREE_CODE(type))
{
case RECORD_TYPE:
- {
- if (go_non_zero_struct == NULL_TREE)
- {
- type = make_node(RECORD_TYPE);
- tree field = build_decl(UNKNOWN_LOCATION, FIELD_DECL,
- get_identifier("dummy"),
- boolean_type_node);
- DECL_CONTEXT(field) = type;
- TYPE_FIELDS(type) = field;
- layout_type(type);
- go_non_zero_struct = type;
- }
- return go_non_zero_struct;
- }
+ if (TYPE_FIELDS(type) != NULL_TREE)
+ {
+ tree ns = make_node(RECORD_TYPE);
+ tree field_trees = NULL_TREE;
+ tree *pp = &field_trees;
+ for (tree field = TYPE_FIELDS(type);
+ field != NULL_TREE;
+ field = DECL_CHAIN(field))
+ {
+ tree ft = TREE_TYPE(field);
+ if (field == TYPE_FIELDS(type))
+ ft = non_zero_size_type(ft);
+ tree f = build_decl(DECL_SOURCE_LOCATION(field), FIELD_DECL,
+ DECL_NAME(field), ft);
+ DECL_CONTEXT(f) = ns;
+ *pp = f;
+ pp = &DECL_CHAIN(f);
+ }
+ TYPE_FIELDS(ns) = field_trees;
+ layout_type(ns);
+ return ns;
+ }
+
+ if (go_non_zero_struct == NULL_TREE)
+ {
+ type = make_node(RECORD_TYPE);
+ tree field = build_decl(UNKNOWN_LOCATION, FIELD_DECL,
+ get_identifier("dummy"),
+ boolean_type_node);
+ DECL_CONTEXT(field) = type;
+ TYPE_FIELDS(type) = field;
+ layout_type(type);
+ go_non_zero_struct = type;
+ }
+ return go_non_zero_struct;
case ARRAY_TYPE:
{