Commit 6df020c0 by Ian Lance Taylor

compiler: Fix crash: type T1 struct { F *[1]T2 } where T2 is a struct.

This will become bug417.go.

From-SVN: r184299
parent cc8b9c31
...@@ -522,8 +522,8 @@ Expression::convert_interface_to_interface(Translate_context* context, ...@@ -522,8 +522,8 @@ Expression::convert_interface_to_interface(Translate_context* context,
// first field is just the type descriptor of the object. // first field is just the type descriptor of the object.
go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
"__type_descriptor") == 0); "__type_descriptor") == 0);
go_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor)); elt->value = fold_convert_loc(location.gcc_location(),
elt->value = rhs_type_descriptor; TREE_TYPE(field), rhs_type_descriptor);
} }
else else
{ {
......
...@@ -2929,8 +2929,6 @@ Gogo::convert_named_types() ...@@ -2929,8 +2929,6 @@ Gogo::convert_named_types()
Runtime::convert_types(this); Runtime::convert_types(this);
Function_type::convert_types(this);
this->named_types_are_converted_ = true; this->named_types_are_converted_ = true;
} }
......
...@@ -852,6 +852,16 @@ class Type ...@@ -852,6 +852,16 @@ class Type
Btype* Btype*
get_backend(Gogo*); get_backend(Gogo*);
// Return a placeholder for the backend representation of the type.
// This will return a type of the correct size, but for which some
// of the fields may still need to be completed.
Btype*
get_backend_placeholder(Gogo*);
// Finish the backend representation of a placeholder.
void
finish_backend(Gogo*);
// Build a type descriptor entry for this type. Return a pointer to // Build a type descriptor entry for this type. Return a pointer to
// it. The location is the location which causes us to need the // it. The location is the location which causes us to need the
// entry. // entry.
...@@ -1179,6 +1189,9 @@ class Type ...@@ -1179,6 +1189,9 @@ class Type
// The type classification. // The type classification.
Type_classification classification_; Type_classification classification_;
// Whether btype_ is a placeholder type used while named types are
// being converted.
bool btype_is_placeholder_;
// The backend representation of the type, once it has been // The backend representation of the type, once it has been
// determined. // determined.
Btype* btype_; Btype* btype_;
...@@ -1730,10 +1743,6 @@ class Function_type : public Type ...@@ -1730,10 +1743,6 @@ class Function_type : public Type
Function_type* Function_type*
copy_with_receiver(Type*) const; copy_with_receiver(Type*) const;
// Finishing converting function types.
static void
convert_types(Gogo*);
static Type* static Type*
make_function_type_descriptor_type(); make_function_type_descriptor_type();
...@@ -1773,16 +1782,6 @@ class Function_type : public Type ...@@ -1773,16 +1782,6 @@ class Function_type : public Type
type_descriptor_params(Type*, const Typed_identifier*, type_descriptor_params(Type*, const Typed_identifier*,
const Typed_identifier_list*); const Typed_identifier_list*);
Btype*
get_function_backend(Gogo*);
// A list of function types with multiple results and their
// placeholder backend representations, used to postpone building
// the structs we use for multiple results until all types are
// converted.
typedef std::vector<std::pair<Function_type*, Btype*> > Placeholders;
static Placeholders placeholders;
// The receiver name and type. This will be NULL for a normal // The receiver name and type. This will be NULL for a normal
// function, non-NULL for a method. // function, non-NULL for a method.
Typed_identifier* receiver_; Typed_identifier* receiver_;
...@@ -2079,6 +2078,10 @@ class Struct_type : public Type ...@@ -2079,6 +2078,10 @@ class Struct_type : public Type
bool bool
backend_field_offset(Gogo*, unsigned int index, unsigned int* poffset); backend_field_offset(Gogo*, unsigned int index, unsigned int* poffset);
// Finish the backend representation of all the fields.
void
finish_backend_fields(Gogo*);
// Import a struct type. // Import a struct type.
static Struct_type* static Struct_type*
do_import(Import*); do_import(Import*);
...@@ -2193,12 +2196,16 @@ class Array_type : public Type ...@@ -2193,12 +2196,16 @@ class Array_type : public Type
// Return the backend representation of the element type. // Return the backend representation of the element type.
Btype* Btype*
get_backend_element(Gogo*); get_backend_element(Gogo*, bool use_placeholder);
// Return the backend representation of the length. // Return the backend representation of the length.
Bexpression* Bexpression*
get_backend_length(Gogo*); get_backend_length(Gogo*);
// Finish the backend representation of the element type.
void
finish_backend_element(Gogo*);
static Type* static Type*
make_array_type_descriptor_type(); make_array_type_descriptor_type();
...@@ -2521,6 +2528,10 @@ class Interface_type : public Type ...@@ -2521,6 +2528,10 @@ class Interface_type : public Type
static Btype* static Btype*
get_backend_empty_interface_type(Gogo*); get_backend_empty_interface_type(Gogo*);
// Finish the backend representation of the method types.
void
finish_backend_methods(Gogo*);
static Type* static Type*
make_interface_type_descriptor_type(); make_interface_type_descriptor_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