Commit f1e18725 by Ian Lance Taylor Committed by Ian Lance Taylor

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
parent 08d22f9b
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".
......
......@@ -1242,7 +1242,29 @@ Gcc_backend::non_zero_size_type(tree type)
switch (TREE_CODE(type))
{
case RECORD_TYPE:
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);
......@@ -1255,7 +1277,6 @@ Gcc_backend::non_zero_size_type(tree type)
go_non_zero_struct = type;
}
return go_non_zero_struct;
}
case ARRAY_TYPE:
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment