aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/go-gcc.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2012-01-21 22:50:36 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-01-21 22:50:36 +0000
commit08be22dc96b89851dea8a69afe51f8bc245facc1 (patch)
treeba911f21b3399364f691e4f99f6c86710225dae3 /gcc/go/go-gcc.cc
parent8f94383a99eddb3c7c6b94ffaa3528c0e22c68c2 (diff)
downloadgcc-08be22dc96b89851dea8a69afe51f8bc245facc1.zip
gcc-08be22dc96b89851dea8a69afe51f8bc245facc1.tar.gz
gcc-08be22dc96b89851dea8a69afe51f8bc245facc1.tar.bz2
compiler: The type descriptor of an undefined forward type is an error.
* go-gcc.cc (Gcc_backend::type_size): Check for error_mark_node. (Gcc_backend::type_alignment): Likewise. (Gcc_backend::type_field_alignment): Likewise. (Gcc_backend::type_field_offset): Likewise. From-SVN: r183381
Diffstat (limited to 'gcc/go/go-gcc.cc')
-rw-r--r--gcc/go/go-gcc.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index ca0d626b..e6967a8 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -778,7 +778,10 @@ Gcc_backend::is_circular_pointer_type(Btype* btype)
size_t
Gcc_backend::type_size(Btype* btype)
{
- tree t = TYPE_SIZE_UNIT(btype->get_tree());
+ tree t = btype->get_tree();
+ if (t == error_mark_node)
+ return 1;
+ t = TYPE_SIZE_UNIT(t);
gcc_assert(TREE_CODE(t) == INTEGER_CST);
gcc_assert(TREE_INT_CST_HIGH(t) == 0);
unsigned HOST_WIDE_INT val_wide = TREE_INT_CST_LOW(t);
@@ -792,7 +795,10 @@ Gcc_backend::type_size(Btype* btype)
size_t
Gcc_backend::type_alignment(Btype* btype)
{
- return TYPE_ALIGN_UNIT(btype->get_tree());
+ tree t = btype->get_tree();
+ if (t == error_mark_node)
+ return 1;
+ return TYPE_ALIGN_UNIT(t);
}
// Return the alignment of a struct field of type BTYPE.
@@ -800,7 +806,10 @@ Gcc_backend::type_alignment(Btype* btype)
size_t
Gcc_backend::type_field_alignment(Btype* btype)
{
- return go_field_alignment(btype->get_tree());
+ tree t = btype->get_tree();
+ if (t == error_mark_node)
+ return 1;
+ return go_field_alignment(t);
}
// Return the offset of a field in a struct.
@@ -809,6 +818,8 @@ size_t
Gcc_backend::type_field_offset(Btype* btype, size_t index)
{
tree struct_tree = btype->get_tree();
+ if (struct_tree == error_mark_node)
+ return 0;
gcc_assert(TREE_CODE(struct_tree) == RECORD_TYPE);
tree field = TYPE_FIELDS(struct_tree);
for (; index > 0; --index)