Commit dbbc4d4c by Ian Lance Taylor Committed by Ian Lance Taylor

godump.c (go_format_type): Check for invalid type names, pointer target types,…

godump.c (go_format_type): Check for invalid type names, pointer target types, and struct field types.

	* godump.c (go_format_type): Check for invalid type names, pointer
	target types, and struct field types.

From-SVN: r174253
parent 45e4e4e2
2011-05-25 Ian Lance Taylor <iant@google.com>
* godump.c (go_format_type): Check for invalid type names, pointer
target types, and struct field types.
2011-05-25 Jason Merrill <jason@redhat.com> 2011-05-25 Jason Merrill <jason@redhat.com>
* print-tree.c (print_node): Only look at TREE_TYPE if TS_TYPED. * print-tree.c (print_node): Only look at TREE_TYPE if TS_TYPED.
......
...@@ -532,8 +532,18 @@ go_format_type (struct godump_container *container, tree type, ...@@ -532,8 +532,18 @@ go_format_type (struct godump_container *container, tree type,
break; break;
case TYPE_DECL: case TYPE_DECL:
obstack_1grow (ob, '_'); {
go_append_string (ob, DECL_NAME (type)); void **slot;
slot = htab_find_slot (container->invalid_hash,
IDENTIFIER_POINTER (DECL_NAME (type)),
NO_INSERT);
if (slot != NULL)
ret = false;
obstack_1grow (ob, '_');
go_append_string (ob, DECL_NAME (type));
}
break; break;
case INTEGER_TYPE: case INTEGER_TYPE:
...@@ -604,31 +614,28 @@ go_format_type (struct godump_container *container, tree type, ...@@ -604,31 +614,28 @@ go_format_type (struct godump_container *container, tree type,
== FUNCTION_TYPE)))) == FUNCTION_TYPE))))
{ {
tree name; tree name;
void **slot;
name = TYPE_NAME (TREE_TYPE (type)); name = TYPE_NAME (TREE_TYPE (type));
if (TREE_CODE (name) == IDENTIFIER_NODE) if (TREE_CODE (name) == TYPE_DECL)
{ name = DECL_NAME (name);
obstack_grow (ob, "*_", 2);
go_append_string (ob, name);
/* The pointer here can be used without the struct or slot = htab_find_slot (container->invalid_hash,
union definition. So this struct or union is a a IDENTIFIER_POINTER (name), NO_INSERT);
potential dummy type. */ if (slot != NULL)
if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type))) ret = false;
pointer_set_insert (container->pot_dummy_types,
IDENTIFIER_POINTER (name));
return ret; obstack_grow (ob, "*_", 2);
} go_append_string (ob, name);
else if (TREE_CODE (name) == TYPE_DECL)
{ /* The pointer here can be used without the struct or union
obstack_grow (ob, "*_", 2); definition. So this struct or union is a potential dummy
go_append_string (ob, DECL_NAME (name)); type. */
if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type))) if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type)))
pointer_set_insert (container->pot_dummy_types, pointer_set_insert (container->pot_dummy_types,
IDENTIFIER_POINTER (DECL_NAME (name))); IDENTIFIER_POINTER (name));
return ret;
} return ret;
} }
if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE) if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
obstack_grow (ob, "func", 4); obstack_grow (ob, "func", 4);
...@@ -716,17 +723,21 @@ go_format_type (struct godump_container *container, tree type, ...@@ -716,17 +723,21 @@ go_format_type (struct godump_container *container, tree type,
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (field))) && (TREE_CODE (TREE_TYPE (TREE_TYPE (field)))
== FUNCTION_TYPE)))) == FUNCTION_TYPE))))
{ {
tree name = TYPE_NAME (TREE_TYPE (field)); tree name;
if (TREE_CODE (name) == IDENTIFIER_NODE) void **slot;
{
obstack_1grow (ob, '_'); name = TYPE_NAME (TREE_TYPE (field));
go_append_string (ob, name); if (TREE_CODE (name) == TYPE_DECL)
} name = DECL_NAME (name);
else if (TREE_CODE (name) == TYPE_DECL)
{ slot = htab_find_slot (container->invalid_hash,
obstack_1grow (ob, '_'); IDENTIFIER_POINTER (name),
go_append_string (ob, DECL_NAME (name)); NO_INSERT);
} if (slot != NULL)
ret = false;
obstack_1grow (ob, '_');
go_append_string (ob, name);
} }
else else
{ {
......
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