From 8ca93ccfd2f266eaca01dc053bee934a6b0fb24e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 3 Mar 2011 00:42:10 +0000 Subject: [PATCH] Don't crash if a constant has a declared but undefined type. From-SVN: r170632 --- gcc/go/gofrontend/gogo-tree.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index 722a23a52d7..883b5b11846 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -926,7 +926,16 @@ Named_object::get_tree(Gogo* gogo, Named_object* function) { Type* type = named_constant->type(); if (type != NULL && !type->is_abstract()) - expr_tree = fold_convert(type->get_tree(gogo), expr_tree); + { + if (!type->is_undefined()) + expr_tree = fold_convert(type->get_tree(gogo), expr_tree); + else + { + // Make sure we report the error. + type->base(); + expr_tree = error_mark_node; + } + } if (expr_tree == error_mark_node) decl = error_mark_node; else if (INTEGRAL_TYPE_P(TREE_TYPE(expr_tree))) -- 2.30.2