Commit dcf30625 by Ian Lance Taylor Committed by Ian Lance Taylor

go-gcc.cc (set_placeholder_pointer_type): Arrange for the type name to have a…

go-gcc.cc (set_placeholder_pointer_type): Arrange for the type name to have a DECL_ORIGINAL_TYPE as gcc expects.

	* go-gcc.cc (set_placeholder_pointer_type): Arrange for the type
	name to have a DECL_ORIGINAL_TYPE as gcc expects.
	(set_placeholder_struct_type): Likewise.
	(set_placeholder_array_type): Likewise.
	(named_type): Set DECL_ORIGINAL_TYPE.

From-SVN: r182639
parent 42dfafa9
2011-12-22 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (set_placeholder_pointer_type): Arrange for the type
name to have a DECL_ORIGINAL_TYPE as gcc expects.
(set_placeholder_struct_type): Likewise.
(set_placeholder_array_type): Likewise.
(named_type): Set DECL_ORIGINAL_TYPE.
2011-12-13 Ian Lance Taylor <iant@google.com> 2011-12-13 Ian Lance Taylor <iant@google.com>
* go-backend.c: #include "simple-object.h" and "intl.h". * go-backend.c: #include "simple-object.h" and "intl.h".
......
...@@ -619,6 +619,13 @@ Gcc_backend::set_placeholder_pointer_type(Btype* placeholder, ...@@ -619,6 +619,13 @@ Gcc_backend::set_placeholder_pointer_type(Btype* placeholder,
} }
gcc_assert(TREE_CODE(tt) == POINTER_TYPE); gcc_assert(TREE_CODE(tt) == POINTER_TYPE);
TREE_TYPE(pt) = TREE_TYPE(tt); TREE_TYPE(pt) = TREE_TYPE(tt);
if (TYPE_NAME(pt) != NULL_TREE)
{
// Build the data structure gcc wants to see for a typedef.
tree copy = build_variant_type_copy(pt);
TYPE_NAME(copy) = NULL_TREE;
DECL_ORIGINAL_TYPE(TYPE_NAME(pt)) = copy;
}
return true; return true;
} }
...@@ -654,6 +661,12 @@ Gcc_backend::set_placeholder_struct_type( ...@@ -654,6 +661,12 @@ Gcc_backend::set_placeholder_struct_type(
tree t = placeholder->get_tree(); tree t = placeholder->get_tree();
gcc_assert(TREE_CODE(t) == RECORD_TYPE && TYPE_FIELDS(t) == NULL_TREE); gcc_assert(TREE_CODE(t) == RECORD_TYPE && TYPE_FIELDS(t) == NULL_TREE);
Btype* r = this->fill_in_struct(placeholder, fields); Btype* r = this->fill_in_struct(placeholder, fields);
// Build the data structure gcc wants to see for a typedef.
tree copy = build_variant_type_copy(t);
TYPE_NAME(copy) = NULL_TREE;
DECL_ORIGINAL_TYPE(TYPE_NAME(t)) = copy;
return r->get_tree() != error_mark_node; return r->get_tree() != error_mark_node;
} }
...@@ -681,6 +694,12 @@ Gcc_backend::set_placeholder_array_type(Btype* placeholder, ...@@ -681,6 +694,12 @@ Gcc_backend::set_placeholder_array_type(Btype* placeholder,
tree t = placeholder->get_tree(); tree t = placeholder->get_tree();
gcc_assert(TREE_CODE(t) == ARRAY_TYPE && TREE_TYPE(t) == NULL_TREE); gcc_assert(TREE_CODE(t) == ARRAY_TYPE && TREE_TYPE(t) == NULL_TREE);
Btype* r = this->fill_in_array(placeholder, element_btype, length); Btype* r = this->fill_in_array(placeholder, element_btype, length);
// Build the data structure gcc wants to see for a typedef.
tree copy = build_variant_type_copy(t);
TYPE_NAME(copy) = NULL_TREE;
DECL_ORIGINAL_TYPE(TYPE_NAME(t)) = copy;
return r->get_tree() != error_mark_node; return r->get_tree() != error_mark_node;
} }
...@@ -693,12 +712,13 @@ Gcc_backend::named_type(const std::string& name, Btype* btype, ...@@ -693,12 +712,13 @@ Gcc_backend::named_type(const std::string& name, Btype* btype,
tree type = btype->get_tree(); tree type = btype->get_tree();
if (type == error_mark_node) if (type == error_mark_node)
return this->error_type(); return this->error_type();
type = build_variant_type_copy(type); tree copy = build_variant_type_copy(type);
tree decl = build_decl(location.gcc_location(), TYPE_DECL, tree decl = build_decl(location.gcc_location(), TYPE_DECL,
get_identifier_from_string(name), get_identifier_from_string(name),
type); copy);
TYPE_NAME(type) = decl; DECL_ORIGINAL_TYPE(decl) = type;
return this->make_type(type); TYPE_NAME(copy) = decl;
return this->make_type(copy);
} }
// Return a pointer type used as a marker for a circular type. // Return a pointer type used as a marker for a circular 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