From 26409c5246d31c7709ea85e8fea698d38bfb161d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 21 Apr 2011 22:54:23 +0000 Subject: [PATCH] Define go_assert to replace gcc_assert This is defined in go-system.h in the backend. * go-system.h (go_assert, go_unreachable): Define. From-SVN: r172846 --- gcc/go/ChangeLog | 4 + gcc/go/go-system.h | 6 + gcc/go/gofrontend/README | 2 +- gcc/go/gofrontend/dataflow.cc | 4 +- gcc/go/gofrontend/export.cc | 12 +- gcc/go/gofrontend/expressions.cc | 286 +++++++++++++-------------- gcc/go/gofrontend/expressions.h | 2 +- gcc/go/gofrontend/go.cc | 4 +- gcc/go/gofrontend/gogo-tree.cc | 106 +++++----- gcc/go/gofrontend/gogo.cc | 134 ++++++------- gcc/go/gofrontend/gogo.h | 58 +++--- gcc/go/gofrontend/import.cc | 12 +- gcc/go/gofrontend/lex.cc | 10 +- gcc/go/gofrontend/lex.h | 16 +- gcc/go/gofrontend/parse.cc | 88 ++++----- gcc/go/gofrontend/runtime.cc | 12 +- gcc/go/gofrontend/statements.cc | 84 ++++---- gcc/go/gofrontend/statements.h | 16 +- gcc/go/gofrontend/types.cc | 320 +++++++++++++++---------------- gcc/go/gofrontend/types.h | 16 +- gcc/go/gofrontend/unsafe.cc | 8 +- 21 files changed, 605 insertions(+), 595 deletions(-) diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 5e8ad86821b..aa713dbb0a8 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2011-04-21 Ian Lance Taylor + + * go-system.h (go_assert, go_unreachable): Define. + 2011-04-19 Ian Lance Taylor * go-system.h: Include "intl.h". diff --git a/gcc/go/go-system.h b/gcc/go/go-system.h index 75f39254377..08aac6a0f72 100644 --- a/gcc/go/go-system.h +++ b/gcc/go/go-system.h @@ -151,4 +151,10 @@ extern "C" } // End extern "C" #endif +// When using gcc, go_assert is just gcc_assert. +#define go_assert(EXPR) gcc_assert(EXPR) + +// When using gcc, go_unreachable is just gcc_unreachable. +#define go_unreachable() gcc_unreachable() + #endif // !defined(GO_SYSTEM_H) diff --git a/gcc/go/gofrontend/README b/gcc/go/gofrontend/README index 859659e756e..c2c9e76fd70 100644 --- a/gcc/go/gofrontend/README +++ b/gcc/go/gofrontend/README @@ -24,7 +24,7 @@ Issues to be faced in this transition: features such as %<%> for appropriate quoting. + Localization may be an issue. -* Use of gcc_assert and gcc_unreachable. +* Use of gcc_unreachable. This compiler works, but the code is a work in progress. Notably, the support for garbage collection is ineffective and needs a complete diff --git a/gcc/go/gofrontend/dataflow.cc b/gcc/go/gofrontend/dataflow.cc index 8170d0ac18e..94f26286b50 100644 --- a/gcc/go/gofrontend/dataflow.cc +++ b/gcc/go/gofrontend/dataflow.cc @@ -49,7 +49,7 @@ get_var(Expression* expr) if (ve == NULL) return NULL; Named_object* no = ve->named_object(); - gcc_assert(no->is_variable() || no->is_result_variable()); + go_assert(no->is_variable() || no->is_result_variable()); if (no->is_variable() && no->var_value()->is_global()) return NULL; return no; @@ -103,7 +103,7 @@ Dataflow_traverse_assignment::initialize_variable(Named_object* var) { Expression* e = init; this->value(&e, true, true); - gcc_assert(e == init); + go_assert(e == init); } } diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc index cbf24b84025..538fb97ce68 100644 --- a/gcc/go/gofrontend/export.cc +++ b/gcc/go/gofrontend/export.cc @@ -266,7 +266,7 @@ Export::write_type(const Type* type) { // This type was already in the table. int index = p->second; - gcc_assert(index != 0); + go_assert(index != 0); char buf[30]; snprintf(buf, sizeof buf, "", index); this->write_c_string(buf); @@ -289,7 +289,7 @@ Export::write_type(const Type* type) if (named_type != NULL) { // The builtin types should have been predefined. - gcc_assert(named_type->location() != BUILTINS_LOCATION + go_assert(named_type->location() != BUILTINS_LOCATION || (named_type->named_object()->package()->name() == "unsafe")); named_object = named_type->named_object(); @@ -355,16 +355,16 @@ void Export::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) { Named_object* named_object = gogo->lookup_global(name); - gcc_assert(named_object != NULL && named_object->is_type()); + go_assert(named_object != NULL && named_object->is_type()); std::pair ins = this->type_refs_.insert(std::make_pair(named_object->type_value(), code)); - gcc_assert(ins.second); + go_assert(ins.second); // We also insert the underlying type. We can see the underlying // type at least for string and bool. Type* real_type = named_object->type_value()->real_type(); ins = this->type_refs_.insert(std::make_pair(real_type, code)); - gcc_assert(ins.second); + go_assert(ins.second); } // Class Export::Stream. @@ -428,7 +428,7 @@ Stream_to_section::do_write(const char* bytes, size_t length) section* sec = (section*) this->section_; if (sec == NULL) { - gcc_assert(targetm.have_named_sections); + go_assert(targetm.have_named_sections); sec = get_section(".go_export", SECTION_DEBUG, NULL); this->section_ = (void*) sec; diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 8a1fc349b95..ee065bfefab 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -236,27 +236,27 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, && rhs_type->is_nil_type()) { // Assigning nil to an open array. - gcc_assert(TREE_CODE(lhs_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(lhs_type_tree) == RECORD_TYPE); VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3); constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); tree field = TYPE_FIELDS(lhs_type_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), null_pointer_node); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), integer_zero_node); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), integer_zero_node); @@ -270,7 +270,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, { // The left hand side should be a pointer type at the tree // level. - gcc_assert(POINTER_TYPE_P(lhs_type_tree)); + go_assert(POINTER_TYPE_P(lhs_type_tree)); return fold_convert(lhs_type_tree, null_pointer_node); } else if (lhs_type_tree == TREE_TYPE(rhs_tree)) @@ -288,14 +288,14 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type, { // This conversion must be permitted by Go, or we wouldn't have // gotten here. - gcc_assert(int_size_in_bytes(lhs_type_tree) + go_assert(int_size_in_bytes(lhs_type_tree) == int_size_in_bytes(TREE_TYPE(rhs_tree))); return fold_build1_loc(location, VIEW_CONVERT_EXPR, lhs_type_tree, rhs_tree); } else { - gcc_assert(useless_type_conversion_p(lhs_type_tree, TREE_TYPE(rhs_tree))); + go_assert(useless_type_conversion_p(lhs_type_tree, TREE_TYPE(rhs_tree))); return rhs_tree; } } @@ -321,7 +321,7 @@ Expression::convert_type_to_interface(Translate_context* context, return lhs_type->get_init_tree(gogo, false); // This should have been checked already. - gcc_assert(lhs_interface_type->implements_interface(rhs_type, NULL)); + go_assert(lhs_interface_type->implements_interface(rhs_type, NULL)); tree lhs_type_tree = lhs_type->get_tree(gogo); if (lhs_type_tree == error_mark_node) @@ -364,14 +364,14 @@ Expression::convert_type_to_interface(Translate_context* context, constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); tree field = TYPE_FIELDS(lhs_type_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), (lhs_is_empty ? "__type_descriptor" : "__methods")) == 0); elt->index = field; elt->value = fold_convert_loc(location, TREE_TYPE(field), first_field_value); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); elt->index = field; if (rhs_type->points_to() != NULL) @@ -413,25 +413,25 @@ Expression::get_interface_type_descriptor(Translate_context*, source_location location) { tree rhs_type_tree = TREE_TYPE(rhs_tree); - gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); tree rhs_field = TYPE_FIELDS(rhs_type_tree); tree v = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field, NULL_TREE); if (rhs_type->interface_type()->is_empty()) { - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__type_descriptor") == 0); return v; } - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__methods") + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__methods") == 0); - gcc_assert(POINTER_TYPE_P(TREE_TYPE(v))); + go_assert(POINTER_TYPE_P(TREE_TYPE(v))); v = save_expr(v); tree v1 = build_fold_indirect_ref_loc(location, v); - gcc_assert(TREE_CODE(TREE_TYPE(v1)) == RECORD_TYPE); + go_assert(TREE_CODE(TREE_TYPE(v1)) == RECORD_TYPE); tree f = TYPE_FIELDS(TREE_TYPE(v1)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(f)), "__type_descriptor") + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(f)), "__type_descriptor") == 0); v1 = build3(COMPONENT_REF, TREE_TYPE(f), v1, f, NULL_TREE); @@ -510,16 +510,16 @@ Expression::convert_interface_to_interface(Translate_context* context, { // A convertion to an empty interface always succeeds, and the // first field is just the type descriptor of the object. - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__type_descriptor") == 0); - gcc_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor)); + go_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor)); elt->value = rhs_type_descriptor; } else { // A conversion to a non-empty interface may fail, but unlike a // type assertion converting nil will always succeed. - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0); tree lhs_type_descriptor = lhs_type->type_descriptor_pointer(gogo); static tree convert_interface_decl; @@ -543,13 +543,13 @@ Expression::convert_interface_to_interface(Translate_context* context, elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); elt->index = field; tree rhs_type_tree = TREE_TYPE(rhs_tree); - gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0); elt->value = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field, NULL_TREE); @@ -604,9 +604,9 @@ Expression::convert_interface_to_type(Translate_context* context, TREE_NOTHROW(check_interface_type_decl) = 0; // If the call succeeds, pull out the value. - gcc_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(rhs_type_tree) == RECORD_TYPE); tree rhs_field = DECL_CHAIN(TYPE_FIELDS(rhs_type_tree)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(rhs_field)), "__object") == 0); tree val = build3(COMPONENT_REF, TREE_TYPE(rhs_field), rhs_tree, rhs_field, NULL_TREE); @@ -902,7 +902,7 @@ Parser_expression::do_type() // However, it can happen, at least when we have an invalid const // whose initializer refers to the const itself. In that case we // may ask for the type when lowering the const itself. - gcc_assert(saw_errors()); + go_assert(saw_errors()); return Type::make_error_type(); } @@ -1118,7 +1118,7 @@ Sink_expression::do_get_tree(Translate_context* context) { if (this->var_ == NULL_TREE) { - gcc_assert(this->type_ != NULL && !this->type_->is_sink_type()); + go_assert(this->type_ != NULL && !this->type_->is_sink_type()); this->var_ = create_tmp_var(this->type_->get_tree(context->gogo()), "blank"); } @@ -1219,7 +1219,7 @@ Func_expression::do_get_tree(Translate_context* context) if (fnaddr == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(fnaddr) == ADDR_EXPR + go_assert(TREE_CODE(fnaddr) == ADDR_EXPR && TREE_CODE(TREE_OPERAND(fnaddr, 0)) == FUNCTION_DECL); TREE_ADDRESSABLE(TREE_OPERAND(fnaddr, 0)) = 1; @@ -1227,7 +1227,7 @@ Func_expression::do_get_tree(Translate_context* context) if (!this->function_->is_function() || this->function_->func_value()->enclosing() == NULL) { - gcc_assert(this->closure_ == NULL); + go_assert(this->closure_ == NULL); return fnaddr; } @@ -1245,7 +1245,7 @@ Func_expression::do_get_tree(Translate_context* context) closure_tree = closure->get_tree(context); if (closure_tree == error_mark_node) return error_mark_node; - gcc_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree))); + go_assert(POINTER_TYPE_P(TREE_TYPE(closure_tree))); } // Now we need to build some code on the heap. This code will load @@ -1330,7 +1330,7 @@ Unknown_expression::do_lower(Gogo*, Named_object*, int) Expression* Expression::make_unknown_reference(Named_object* no, source_location location) { - gcc_assert(no->resolve()->is_unknown()); + go_assert(no->resolve()->is_unknown()); return new Unknown_expression(no, location); } @@ -2009,7 +2009,7 @@ Float_expression::do_check_types(Gogo*) this->report_error(_("floating point constant truncated to integer")); else { - gcc_assert(!integer_type->is_abstract()); + go_assert(!integer_type->is_abstract()); mpz_t ival; mpz_init(ival); mpfr_get_z(ival, this->val_, GMP_RNDN); @@ -3422,7 +3422,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) expr_tree = save_expr(expr_tree); Array_type* a = t->array_type(); Type* e = a->element_type()->forwarded(); - gcc_assert(e->integer_type() != NULL); + go_assert(e->integer_type() != NULL); tree valptr = fold_convert(const_ptr_type_node, a->value_pointer_tree(gogo, expr_tree)); tree len = a->length_tree(gogo, expr_tree); @@ -3443,7 +3443,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) } else { - gcc_assert(e == Type::lookup_integer_type("int")); + go_assert(e == Type::lookup_integer_type("int")); static tree int_array_to_string_fndecl; ret = Gogo::call_builtin(&int_array_to_string_fndecl, this->location(), @@ -3459,7 +3459,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) else if (type->is_open_array_type() && expr_type->is_string_type()) { Type* e = type->array_type()->element_type()->forwarded(); - gcc_assert(e->integer_type() != NULL); + go_assert(e->integer_type() != NULL); if (e->integer_type()->is_unsigned() && e->integer_type()->bits() == 8) { @@ -3474,7 +3474,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context) } else { - gcc_assert(e == Type::lookup_integer_type("int")); + go_assert(e == Type::lookup_integer_type("int")); static tree string_to_int_array_fndecl; ret = Gogo::call_builtin(&string_to_int_array_fndecl, this->location(), @@ -3611,36 +3611,36 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context) bool use_view_convert = false; if (t->is_open_array_type()) { - gcc_assert(et->is_open_array_type()); + go_assert(et->is_open_array_type()); use_view_convert = true; } else if (t->map_type() != NULL) - gcc_assert(et->map_type() != NULL); + go_assert(et->map_type() != NULL); else if (t->channel_type() != NULL) - gcc_assert(et->channel_type() != NULL); + go_assert(et->channel_type() != NULL); else if (t->points_to() != NULL && t->points_to()->channel_type() != NULL) - gcc_assert((et->points_to() != NULL + go_assert((et->points_to() != NULL && et->points_to()->channel_type() != NULL) || et->is_nil_type()); else if (t->is_unsafe_pointer_type()) - gcc_assert(et->points_to() != NULL || et->is_nil_type()); + go_assert(et->points_to() != NULL || et->is_nil_type()); else if (et->is_unsafe_pointer_type()) - gcc_assert(t->points_to() != NULL); + go_assert(t->points_to() != NULL); else if (t->interface_type() != NULL && !t->interface_type()->is_empty()) { - gcc_assert(et->interface_type() != NULL + go_assert(et->interface_type() != NULL && !et->interface_type()->is_empty()); use_view_convert = true; } else if (t->interface_type() != NULL && t->interface_type()->is_empty()) { - gcc_assert(et->interface_type() != NULL + go_assert(et->interface_type() != NULL && et->interface_type()->is_empty()); use_view_convert = true; } else if (t->integer_type() != NULL) { - gcc_assert(et->is_boolean_type() + go_assert(et->is_boolean_type() || et->integer_type() != NULL || et->function_type() != NULL || et->points_to() != NULL @@ -3690,7 +3690,7 @@ class Unary_expression : public Expression void set_does_not_escape() { - gcc_assert(this->op_ == OPERATOR_AND); + go_assert(this->op_ == OPERATOR_AND); this->escapes_ = false; } @@ -3950,7 +3950,7 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val, size_t ecount; mpz_export(phwi, &ecount, -1, sizeof(HOST_WIDE_INT), 0, 0, uval); - gcc_assert(ecount <= count); + go_assert(ecount <= count); // Trim down to the number of words required by the type. size_t obits = utype->integer_type()->bits(); @@ -3958,7 +3958,7 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val, ++obits; size_t ocount = ((obits + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT); - gcc_assert(ocount <= count); + go_assert(ocount <= count); for (size_t i = 0; i < ocount; ++i) phwi[i] = ~phwi[i]; @@ -4252,8 +4252,8 @@ Unary_expression::do_get_tree(Translate_context* context) // where we would see one should have been moved onto the heap // at parse time. Taking the address of a nonconstant // constructor will not do what the programmer expects. - gcc_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr)); - gcc_assert(TREE_CODE(expr) != ADDR_EXPR); + go_assert(TREE_CODE(expr) != CONSTRUCTOR || TREE_CONSTANT(expr)); + go_assert(TREE_CODE(expr) != ADDR_EXPR); // Build a decl for a constant constructor. if (TREE_CODE(expr) == CONSTRUCTOR && TREE_CONSTANT(expr)) @@ -4276,7 +4276,7 @@ Unary_expression::do_get_tree(Translate_context* context) case OPERATOR_MULT: { - gcc_assert(POINTER_TYPE_P(TREE_TYPE(expr))); + go_assert(POINTER_TYPE_P(TREE_TYPE(expr))); // If we are dereferencing the pointer to a large struct, we // need to check for nil. We don't bother to check for small @@ -5156,7 +5156,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int) right_type, right_val, location, val)) { - gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND); + go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND); Type* type; if (op == OPERATOR_LSHIFT || op == OPERATOR_RSHIFT) type = left_type; @@ -5240,7 +5240,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int) right_type, right_val, val, location)) { - gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND + go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND && op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT); Type* type; if (left_type == NULL) @@ -5331,7 +5331,7 @@ Binary_expression::do_lower(Gogo*, Named_object*, int) real, imag, location)) { - gcc_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND + go_assert(op != OPERATOR_OROR && op != OPERATOR_ANDAND && op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT); Type* type; if (left_type == NULL) @@ -5983,7 +5983,7 @@ Binary_expression::do_get_tree(Translate_context* context) if (this->left_->type()->is_string_type()) { - gcc_assert(this->op_ == OPERATOR_PLUS); + go_assert(this->op_ == OPERATOR_PLUS); tree string_type = Type::make_string_type()->get_tree(context->gogo()); static tree string_plus_decl; return Gogo::call_builtin(&string_plus_decl, @@ -6036,8 +6036,8 @@ Binary_expression::do_get_tree(Translate_context* context) // This is not true in GENERIC, so we need to insert a conditional. if (is_shift_op) { - gcc_assert(INTEGRAL_TYPE_P(TREE_TYPE(left))); - gcc_assert(this->left_->type()->integer_type() != NULL); + go_assert(INTEGRAL_TYPE_P(TREE_TYPE(left))); + go_assert(this->left_->type()->integer_type() != NULL); int bits = TYPE_PRECISION(TREE_TYPE(left)); tree compare = fold_build2(LT_EXPR, boolean_type_node, right, @@ -6458,12 +6458,12 @@ Expression::comparison_tree(Translate_context* context, Operator op, { if (left_type->interface_type()->is_empty()) { - gcc_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ); + go_assert(op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ); std::swap(left_type, right_type); std::swap(left_tree, right_tree); } - gcc_assert(!left_type->interface_type()->is_empty()); - gcc_assert(right_type->interface_type()->is_empty()); + go_assert(!left_type->interface_type()->is_empty()); + go_assert(right_type->interface_type()->is_empty()); static tree interface_empty_compare_decl; left_tree = Gogo::call_builtin(&interface_empty_compare_decl, location, @@ -6503,7 +6503,7 @@ Expression::comparison_tree(Translate_context* context, Operator op, { // An interface is nil if the first field is nil. tree left_type_tree = TREE_TYPE(left_tree); - gcc_assert(TREE_CODE(left_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(left_type_tree) == RECORD_TYPE); tree field = TYPE_FIELDS(left_type_tree); left_tree = build3(COMPONENT_REF, TREE_TYPE(field), left_tree, field, NULL_TREE); @@ -6511,7 +6511,7 @@ Expression::comparison_tree(Translate_context* context, Operator op, } else { - gcc_assert(POINTER_TYPE_P(TREE_TYPE(left_tree))); + go_assert(POINTER_TYPE_P(TREE_TYPE(left_tree))); right_tree = fold_convert(TREE_TYPE(left_tree), null_pointer_node); } } @@ -6723,7 +6723,7 @@ Builtin_call_expression::Builtin_call_expression(Gogo* gogo, gogo_(gogo), code_(BUILTIN_INVALID), seen_(false) { Func_expression* fnexp = this->fn()->func_expression(); - gcc_assert(fnexp != NULL); + go_assert(fnexp != NULL); const std::string& name(fnexp->named_object()->name()); if (name == "append") this->code_ = BUILTIN_APPEND; @@ -6780,7 +6780,7 @@ void Builtin_call_expression::do_set_recover_arg(Expression* arg) { const Expression_list* args = this->args(); - gcc_assert(args == NULL || args->empty()); + go_assert(args == NULL || args->empty()); Expression_list* new_args = new Expression_list(); new_args->push_back(arg); this->set_args(new_args); @@ -7158,7 +7158,7 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant, if (this->code_ == BUILTIN_SIZEOF) { tree type_size = TYPE_SIZE_UNIT(arg_type_tree); - gcc_assert(TREE_CODE(type_size) == INTEGER_CST); + go_assert(TREE_CODE(type_size) == INTEGER_CST); if (TREE_INT_CST_HIGH(type_size) != 0) return false; unsigned HOST_WIDE_INT val_wide = TREE_INT_CST_LOW(type_size); @@ -7198,12 +7198,12 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant, if (st->named_type() != NULL) st->named_type()->convert(this->gogo_); tree struct_tree = st->get_tree(this->gogo_); - gcc_assert(TREE_CODE(struct_tree) == RECORD_TYPE); + go_assert(TREE_CODE(struct_tree) == RECORD_TYPE); tree field = TYPE_FIELDS(struct_tree); for (unsigned int index = farg->field_index(); index > 0; --index) { field = DECL_CHAIN(field); - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); } HOST_WIDE_INT offset_wide = int_byte_position (field); if (offset_wide < 0) @@ -7747,13 +7747,13 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_CAP: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 1); + go_assert(args != NULL && args->size() == 1); Expression* arg = *args->begin(); Type* arg_type = arg->type(); if (this->seen_) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } this->seen_ = true; @@ -7768,9 +7768,9 @@ Builtin_call_expression::do_get_tree(Translate_context* context) if (arg_type->points_to() != NULL) { arg_type = arg_type->points_to(); - gcc_assert(arg_type->array_type() != NULL + go_assert(arg_type->array_type() != NULL && !arg_type->is_open_array_type()); - gcc_assert(POINTER_TYPE_P(TREE_TYPE(arg_tree))); + go_assert(POINTER_TYPE_P(TREE_TYPE(arg_tree))); arg_tree = build_fold_indirect_ref(arg_tree); } @@ -7783,7 +7783,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) { if (this->seen_) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } this->seen_ = true; @@ -7821,7 +7821,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) { if (this->seen_) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } this->seen_ = true; @@ -8000,7 +8000,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_PANIC: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 1); + go_assert(args != NULL && args->size() == 1); Expression* arg = args->front(); tree arg_tree = arg->get_tree(context); if (arg_tree == error_mark_node) @@ -8031,7 +8031,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) // The argument is set when building recover thunks. It's a // boolean value which is true if we can recover a value now. const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 1); + go_assert(args != NULL && args->size() == 1); Expression* arg = args->front(); tree arg_tree = arg->get_tree(context); if (arg_tree == error_mark_node) @@ -8080,7 +8080,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_CLOSE: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 1); + go_assert(args != NULL && args->size() == 1); Expression* arg = args->front(); tree arg_tree = arg->get_tree(context); if (arg_tree == error_mark_node) @@ -8105,7 +8105,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) bool b = this->integer_constant_value(true, val, &dummy); if (!b) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } tree type = Type::lookup_integer_type("int")->get_tree(gogo); @@ -8117,7 +8117,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_COPY: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 2); + go_assert(args != NULL && args->size() == 2); Expression* arg1 = args->front(); Expression* arg2 = args->back(); @@ -8199,7 +8199,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_APPEND: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 2); + go_assert(args != NULL && args->size() == 2); Expression* arg1 = args->front(); Expression* arg2 = args->back(); @@ -8255,12 +8255,12 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_IMAG: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 1); + go_assert(args != NULL && args->size() == 1); Expression* arg = args->front(); tree arg_tree = arg->get_tree(context); if (arg_tree == error_mark_node) return error_mark_node; - gcc_assert(COMPLEX_FLOAT_TYPE_P(TREE_TYPE(arg_tree))); + go_assert(COMPLEX_FLOAT_TYPE_P(TREE_TYPE(arg_tree))); if (this->code_ == BUILTIN_REAL) return fold_build1_loc(location, REALPART_EXPR, TREE_TYPE(TREE_TYPE(arg_tree)), @@ -8274,14 +8274,14 @@ Builtin_call_expression::do_get_tree(Translate_context* context) case BUILTIN_COMPLEX: { const Expression_list* args = this->args(); - gcc_assert(args != NULL && args->size() == 2); + go_assert(args != NULL && args->size() == 2); tree r = args->front()->get_tree(context); tree i = args->back()->get_tree(context); if (r == error_mark_node || i == error_mark_node) return error_mark_node; - gcc_assert(TYPE_MAIN_VARIANT(TREE_TYPE(r)) + go_assert(TYPE_MAIN_VARIANT(TREE_TYPE(r)) == TYPE_MAIN_VARIANT(TREE_TYPE(i))); - gcc_assert(SCALAR_FLOAT_TYPE_P(TREE_TYPE(r))); + go_assert(SCALAR_FLOAT_TYPE_P(TREE_TYPE(r))); return fold_build2_loc(location, COMPLEX_EXPR, build_complex_type(TREE_TYPE(r)), r, i); @@ -8418,7 +8418,7 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function, int) { Function_type* fntype = this->fn_->type()->function_type(); const Typed_identifier_list* parameters = fntype->parameters(); - gcc_assert(parameters != NULL && !parameters->empty()); + go_assert(parameters != NULL && !parameters->empty()); Type* varargs_type = parameters->back().type(); return this->lower_varargs(gogo, function, varargs_type, parameters->size()); @@ -8443,8 +8443,8 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function, source_location loc = this->location(); - gcc_assert(param_count > 0); - gcc_assert(varargs_type->is_open_array_type()); + go_assert(param_count > 0); + go_assert(varargs_type->is_open_array_type()); size_t arg_count = this->args_ == NULL ? 0 : this->args_->size(); if (arg_count < param_count - 1) @@ -8458,7 +8458,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function, bool push_empty_arg = false; if (old_args == NULL || old_args->empty()) { - gcc_assert(param_count == 1); + go_assert(param_count == 1); push_empty_arg = true; } else @@ -8517,7 +8517,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function, // Lower all the new subexpressions. Expression* ret = this; gogo->lower_expression(function, &ret); - gcc_assert(ret == this); + go_assert(ret == this); return ret; } @@ -8868,7 +8868,7 @@ Call_expression::do_get_tree(Translate_context* context) this->fn_->interface_field_reference_expression(); const bool has_closure = func != NULL && func->closure() != NULL; const bool is_method = bound_method != NULL || interface_method != NULL; - gcc_assert(!fntype->is_method() || is_method); + go_assert(!fntype->is_method() || is_method); int nargs; tree* args; @@ -8880,7 +8880,7 @@ Call_expression::do_get_tree(Translate_context* context) else { const Typed_identifier_list* params = fntype->parameters(); - gcc_assert(params != NULL); + go_assert(params != NULL); nargs = this->args_->size(); int i = is_method ? 1 : 0; @@ -8893,7 +8893,7 @@ Call_expression::do_get_tree(Translate_context* context) pe != this->args_->end(); ++pe, ++pp, ++i) { - gcc_assert(pp != params->end()); + go_assert(pp != params->end()); tree arg_val = (*pe)->get_tree(context); args[i] = Expression::convert_for_assignment(context, pp->type(), @@ -8906,8 +8906,8 @@ Call_expression::do_get_tree(Translate_context* context) return error_mark_node; } } - gcc_assert(pp == params->end()); - gcc_assert(i == nargs); + go_assert(pp == params->end()); + go_assert(i == nargs); } tree rettype = TREE_TYPE(TREE_TYPE(fntype->get_tree(gogo))); @@ -9155,16 +9155,16 @@ Call_result_expression::do_get_tree(Translate_context* context) return error_mark_node; if (TREE_CODE(TREE_TYPE(call_tree)) != RECORD_TYPE) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } tree field = TYPE_FIELDS(TREE_TYPE(call_tree)); for (unsigned int i = 0; i < this->index_; ++i) { - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); field = DECL_CHAIN(field); } - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); return build3(COMPONENT_REF, TREE_TYPE(field), call_tree, field, NULL_TREE); } @@ -9380,7 +9380,7 @@ Array_index_expression::do_check_types(Gogo*) Array_type* array_type = this->array_->type()->array_type(); if (array_type == NULL) { - gcc_assert(this->array_->type()->is_error()); + go_assert(this->array_->type()->is_error()); return; } @@ -9465,7 +9465,7 @@ Array_index_expression::do_get_tree(Translate_context* context) Array_type* array_type = this->array_->type()->array_type(); if (array_type == NULL) { - gcc_assert(this->array_->type()->is_error()); + go_assert(this->array_->type()->is_error()); return error_mark_node; } @@ -9609,25 +9609,25 @@ Array_index_expression::do_get_tree(Translate_context* context) capacity_tree, start_tree); tree struct_tree = this->type()->get_tree(gogo); - gcc_assert(TREE_CODE(struct_tree) == RECORD_TYPE); + go_assert(TREE_CODE(struct_tree) == RECORD_TYPE); VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3); constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); tree field = TYPE_FIELDS(struct_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); elt->index = field; elt->value = value_pointer; elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); elt->index = field; elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_length_tree); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); elt->index = field; elt->value = fold_convert_loc(loc, TREE_TYPE(field), result_capacity_tree); @@ -9916,7 +9916,7 @@ Map_index_expression::get_map_type() const { Map_type* mt = this->map_->type()->deref()->map_type(); if (mt == NULL) - gcc_assert(saw_errors()); + go_assert(saw_errors()); return mt; } @@ -10129,7 +10129,7 @@ Field_reference_expression::do_type() if (type->is_error()) return type; Struct_type* struct_type = type->struct_type(); - gcc_assert(struct_type != NULL); + go_assert(struct_type != NULL); return struct_type->field(this->field_index_)->type(); } @@ -10142,8 +10142,8 @@ Field_reference_expression::do_check_types(Gogo*) if (type->is_error()) return; Struct_type* struct_type = type->struct_type(); - gcc_assert(struct_type != NULL); - gcc_assert(struct_type->field(this->field_index_) != NULL); + go_assert(struct_type != NULL); + go_assert(struct_type->field(this->field_index_) != NULL); } // Get a tree for a field reference. @@ -10155,19 +10155,19 @@ Field_reference_expression::do_get_tree(Translate_context* context) if (struct_tree == error_mark_node || TREE_TYPE(struct_tree) == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(TREE_TYPE(struct_tree)) == RECORD_TYPE); + go_assert(TREE_CODE(TREE_TYPE(struct_tree)) == RECORD_TYPE); tree field = TYPE_FIELDS(TREE_TYPE(struct_tree)); if (field == NULL_TREE) { // This can happen for a type which refers to itself indirectly // and then turns out to be erroneous. - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } for (unsigned int i = this->field_index_; i > 0; --i) { field = DECL_CHAIN(field); - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); } if (TREE_TYPE(field) == error_mark_node) return error_mark_node; @@ -10196,16 +10196,16 @@ Interface_field_reference_expression::get_function_tree(Translate_context*, expr = build_fold_indirect_ref(expr); tree expr_type = TREE_TYPE(expr); - gcc_assert(TREE_CODE(expr_type) == RECORD_TYPE); + go_assert(TREE_CODE(expr_type) == RECORD_TYPE); tree field = TYPE_FIELDS(expr_type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0); tree table = build3(COMPONENT_REF, TREE_TYPE(field), expr, field, NULL_TREE); - gcc_assert(POINTER_TYPE_P(TREE_TYPE(table))); + go_assert(POINTER_TYPE_P(TREE_TYPE(table))); table = build_fold_indirect_ref(table); - gcc_assert(TREE_CODE(TREE_TYPE(table)) == RECORD_TYPE); + go_assert(TREE_CODE(TREE_TYPE(table)) == RECORD_TYPE); std::string name = Gogo::unpack_hidden_name(this->name_); for (field = DECL_CHAIN(TYPE_FIELDS(TREE_TYPE(table))); @@ -10215,7 +10215,7 @@ Interface_field_reference_expression::get_function_tree(Translate_context*, if (name == IDENTIFIER_POINTER(DECL_NAME(field))) break; } - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); return build3(COMPONENT_REF, TREE_TYPE(field), table, field, NULL_TREE); } @@ -10232,10 +10232,10 @@ Interface_field_reference_expression::get_underlying_object_tree( expr = build_fold_indirect_ref(expr); tree expr_type = TREE_TYPE(expr); - gcc_assert(TREE_CODE(expr_type) == RECORD_TYPE); + go_assert(TREE_CODE(expr_type) == RECORD_TYPE); tree field = DECL_CHAIN(TYPE_FIELDS(expr_type)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__object") == 0); return build3(COMPONENT_REF, TREE_TYPE(field), expr, field, NULL_TREE); } @@ -10447,12 +10447,12 @@ Selector_expression::lower_method_expression(Gogo* gogo) if (method != NULL) { method_type = method->type(); - gcc_assert(method_type->is_method()); + go_assert(method_type->is_method()); } else { method_type = imethod->type()->function_type(); - gcc_assert(method_type != NULL && !method_type->is_method()); + go_assert(method_type != NULL && !method_type->is_method()); } const char* const receiver_name = "$this"; @@ -10509,7 +10509,7 @@ Selector_expression::lower_method_expression(Gogo* gogo) location); Named_object* vno = gogo->lookup(receiver_name, NULL); - gcc_assert(vno != NULL); + go_assert(vno != NULL); Expression* ve = Expression::make_var_reference(vno, location); Expression* bm; if (method != NULL) @@ -10536,7 +10536,7 @@ Selector_expression::lower_method_expression(Gogo* gogo) ++p) { vno = gogo->lookup(p->name(), NULL); - gcc_assert(vno != NULL); + go_assert(vno != NULL); args->push_back(Expression::make_var_reference(vno, location)); } } @@ -10920,7 +10920,7 @@ Struct_construction_expression::do_check_types(Gogo*) this->set_is_error(); } } - gcc_assert(pv == this->vals_->end()); + go_assert(pv == this->vals_->end()); } // Return a tree for constructing a struct. @@ -10936,7 +10936,7 @@ Struct_construction_expression::do_get_tree(Translate_context* context) tree type_tree = this->type_->get_tree(gogo); if (type_tree == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(type_tree) == RECORD_TYPE); bool is_constant = true; const Struct_field_list* fields = this->type_->struct_type()->fields(); @@ -10948,7 +10948,7 @@ Struct_construction_expression::do_get_tree(Translate_context* context) field != NULL_TREE; field = DECL_CHAIN(field), ++pf) { - gcc_assert(pf != fields->end()); + go_assert(pf != fields->end()); tree val; if (pv == this->vals_->end()) @@ -10976,7 +10976,7 @@ Struct_construction_expression::do_get_tree(Translate_context* context) if (!TREE_CONSTANT(val)) is_constant = false; } - gcc_assert(pf == fields->end()); + go_assert(pf == fields->end()); tree ret = build_constructor(type_tree, elts); if (is_constant) @@ -11008,7 +11008,7 @@ Expression* Expression::make_struct_composite_literal(Type* type, Expression_list* vals, source_location location) { - gcc_assert(type->struct_type() != NULL); + go_assert(type->struct_type() != NULL); return new Struct_construction_expression(type, vals, location); } @@ -11245,7 +11245,7 @@ class Fixed_array_construction_expression : : Array_construction_expression(EXPRESSION_FIXED_ARRAY_CONSTRUCTION, type, vals, location) { - gcc_assert(type->array_type() != NULL + go_assert(type->array_type() != NULL && type->array_type()->length() != NULL); } @@ -11283,7 +11283,7 @@ class Open_array_construction_expression : public Array_construction_expression : Array_construction_expression(EXPRESSION_OPEN_ARRAY_CONSTRUCTION, type, vals, location) { - gcc_assert(type->array_type() != NULL + go_assert(type->array_type() != NULL && type->array_type()->length() == NULL); } @@ -11312,7 +11312,7 @@ Open_array_construction_expression::do_get_tree(Translate_context* context) Array_type* array_type = this->type()->array_type(); if (array_type == NULL) { - gcc_assert(this->type()->is_error()); + go_assert(this->type()->is_error()); return error_mark_node; } @@ -11413,25 +11413,25 @@ Open_array_construction_expression::do_get_tree(Translate_context* context) tree type_tree = this->type()->get_tree(context->gogo()); if (type_tree == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(type_tree) == RECORD_TYPE); VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3); constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); tree field = TYPE_FIELDS(type_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), space); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), length_tree); elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),"__capacity") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),"__capacity") == 0); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), length_tree); @@ -11454,7 +11454,7 @@ Expression* Expression::make_slice_composite_literal(Type* type, Expression_list* vals, source_location location) { - gcc_assert(type->is_open_array_type()); + go_assert(type->is_open_array_type()); return new Open_array_construction_expression(type, vals, location); } @@ -11467,7 +11467,7 @@ class Map_construction_expression : public Expression source_location location) : Expression(EXPRESSION_MAP_CONSTRUCTION, location), type_(type), vals_(vals) - { gcc_assert(vals == NULL || vals->size() % 2 == 0); } + { go_assert(vals == NULL || vals->size() % 2 == 0); } protected: int @@ -11874,7 +11874,7 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type) Expression* name_expr = *p; ++p; - gcc_assert(p != this->vals_->end()); + go_assert(p != this->vals_->end()); Expression* val = *p; ++p; @@ -12030,7 +12030,7 @@ Composite_literal_expression::lower_array(Type* type) Expression* index_expr = *p; ++p; - gcc_assert(p != this->vals_->end()); + go_assert(p != this->vals_->end()); Expression* val = *p; ++p; @@ -12179,7 +12179,7 @@ Composite_literal_expression::lower_map(Gogo* gogo, Named_object* function, { (*p)->unknown_expression()->clear_is_composite_literal_key(); gogo->lower_expression(function, &*p); - gcc_assert((*p)->is_error_expression()); + go_assert((*p)->is_error_expression()); return Expression::make_error(location); } } @@ -12425,7 +12425,7 @@ Heap_composite_expression::do_get_tree(Translate_context* context) if (expr_tree == error_mark_node) return error_mark_node; tree expr_size = TYPE_SIZE_UNIT(TREE_TYPE(expr_tree)); - gcc_assert(TREE_CODE(expr_size) == INTEGER_CST); + go_assert(TREE_CODE(expr_size) == INTEGER_CST); tree space = context->gogo()->allocate_memory(this->expr_->type(), expr_size, this->location()); space = fold_convert(build_pointer_type(TREE_TYPE(expr_tree)), space); @@ -12491,7 +12491,7 @@ Receive_expression::do_get_tree(Translate_context* context) Channel_type* channel_type = this->channel_->type()->channel_type(); if (channel_type == NULL) { - gcc_assert(this->channel_->type()->is_error()); + go_assert(this->channel_->type()->is_error()); return error_mark_node; } Type* element_type = channel_type->element_type(); @@ -12618,7 +12618,7 @@ Type_info_expression::do_get_tree(Translate_context* context) return error_mark_node; tree val_type_tree = this->type()->get_tree(context->gogo()); - gcc_assert(val_type_tree != error_mark_node); + go_assert(val_type_tree != error_mark_node); if (this->type_info_ == TYPE_INFO_SIZE) return fold_convert_loc(BUILTINS_LOCATION, val_type_tree, @@ -12687,7 +12687,7 @@ Struct_field_offset_expression::do_get_tree(Translate_context* context) return error_mark_node; tree val_type_tree = this->type()->get_tree(context->gogo()); - gcc_assert(val_type_tree != error_mark_node); + go_assert(val_type_tree != error_mark_node); const Struct_field_list* fields = this->type_->fields(); tree struct_field_tree = TYPE_FIELDS(type_tree); @@ -12696,11 +12696,11 @@ Struct_field_offset_expression::do_get_tree(Translate_context* context) p != fields->end(); ++p, struct_field_tree = DECL_CHAIN(struct_field_tree)) { - gcc_assert(struct_field_tree != NULL_TREE); + go_assert(struct_field_tree != NULL_TREE); if (&*p == this->field_) break; } - gcc_assert(&*p == this->field_); + go_assert(&*p == this->field_); return fold_convert_loc(BUILTINS_LOCATION, val_type_tree, byte_position(struct_field_tree)); diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 66aabeb748c..a09d09a41ba 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -1641,7 +1641,7 @@ class Field_reference_expression : public Expression void set_struct_expression(Expression* expr) { - gcc_assert(this->expr_ == NULL); + go_assert(this->expr_ == NULL); this->expr_ = expr; } diff --git a/gcc/go/gofrontend/go.cc b/gcc/go/gofrontend/go.cc index e8729739e12..3da1404129b 100644 --- a/gcc/go/gofrontend/go.cc +++ b/gcc/go/gofrontend/go.cc @@ -27,7 +27,7 @@ GO_EXTERN_C void go_create_gogo(int int_type_size, int pointer_size) { - gcc_assert(::gogo == NULL); + go_assert(::gogo == NULL); ::gogo = new Gogo(go_get_backend(), int_type_size, pointer_size); if (!unique_prefix.empty()) ::gogo->set_unique_prefix(unique_prefix); @@ -60,7 +60,7 @@ void go_parse_input_files(const char** filenames, unsigned int filename_count, bool only_check_syntax, bool require_return_statement) { - gcc_assert(filename_count > 0); + go_assert(filename_count > 0); for (unsigned int i = 0; i < filename_count; ++i) { if (i > 0) diff --git a/gcc/go/gofrontend/gogo-tree.cc b/gcc/go/gofrontend/gogo-tree.cc index af0084f36d4..608f1665d83 100644 --- a/gcc/go/gofrontend/gogo-tree.cc +++ b/gcc/go/gofrontend/gogo-tree.cc @@ -162,7 +162,7 @@ Gogo::get_init_fn_name() { if (this->init_fn_name_.empty()) { - gcc_assert(this->package_ != NULL); + go_assert(this->package_ != NULL); if (this->is_main_package()) { // Use a name which the runtime knows. @@ -188,7 +188,7 @@ Gogo::get_init_fn_name() void Gogo::init_imports(tree* init_stmt_list) { - gcc_assert(this->is_main_package()); + go_assert(this->is_main_package()); if (this->imported_init_fns_.empty()) return; @@ -280,7 +280,7 @@ Gogo::register_gc_vars(const std::vector& var_gc, elt->index = field; Bvariable* bvar = (*p)->get_backend_variable(this, NULL); tree decl = var_to_tree(bvar); - gcc_assert(TREE_CODE(decl) == VAR_DECL); + go_assert(TREE_CODE(decl) == VAR_DECL); elt->value = build_fold_addr_expr(decl); elt = VEC_quick_push(constructor_elt, init, NULL); @@ -387,7 +387,7 @@ Gogo::write_initialization_function(tree fndecl, tree init_stmt_list) { // Make sure that we thought we needed an initialization function, // as otherwise we will not have reported it in the export data. - gcc_assert(this->is_main_package() || this->need_init_fn_); + go_assert(this->is_main_package() || this->need_init_fn_); if (fndecl == NULL_TREE) fndecl = this->initialization_function_decl(); @@ -673,7 +673,7 @@ Gogo::write_globals() { Named_object* no = *p; - gcc_assert(!no->is_type_declaration() && !no->is_function_declaration()); + go_assert(!no->is_type_declaration() && !no->is_function_declaration()); // There is nothing to do for a package. if (no->is_package()) { @@ -711,7 +711,7 @@ Gogo::write_globals() vec[i] = no->get_tree(this, NULL); if (vec[i] == error_mark_node) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); --i; --count; continue; @@ -723,7 +723,7 @@ Gogo::write_globals() vec[i] = var_to_tree(var); if (vec[i] == error_mark_node) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); --i; --count; continue; @@ -738,7 +738,7 @@ Gogo::write_globals() { tree init = no->var_value()->get_init_tree(this, NULL); if (init == error_mark_node) - gcc_assert(saw_errors()); + go_assert(saw_errors()); else if (init == NULL_TREE) ; else if (TREE_CONSTANT(init)) @@ -838,7 +838,7 @@ Gogo::write_globals() tree Named_object::get_id(Gogo* gogo) { - gcc_assert(!this->is_variable() && !this->is_result_variable()); + go_assert(!this->is_variable() && !this->is_result_variable()); std::string decl_name; if (this->is_function_declaration() && !this->func_declaration_value()->asm_name().empty()) @@ -945,7 +945,7 @@ Named_object::get_tree(Gogo* gogo, Named_object* function) else { decl = TYPE_NAME(type_tree); - gcc_assert(decl != NULL_TREE); + go_assert(decl != NULL_TREE); // We need to produce a type descriptor for every named // type, and for a pointer to every named type, since @@ -1028,10 +1028,10 @@ Named_object::get_tree(Gogo* gogo, Named_object* function) tree Variable::get_init_tree(Gogo* gogo, Named_object* function) { - gcc_assert(this->preinit_ == NULL); + go_assert(this->preinit_ == NULL); if (this->init_ == NULL) { - gcc_assert(!this->is_parameter_); + go_assert(!this->is_parameter_); return this->type_->get_init_tree(gogo, (this->is_global_ || this->is_in_heap())); @@ -1052,7 +1052,7 @@ Variable::get_init_tree(Gogo* gogo, Named_object* function) tree Variable::get_init_block(Gogo* gogo, Named_object* function, tree var_decl) { - gcc_assert(this->preinit_ != NULL); + go_assert(this->preinit_ != NULL); // We want to add the variable assignment to the end of the preinit // block. The preinit block may have a TRY_FINALLY_EXPR and a @@ -1064,7 +1064,7 @@ Variable::get_init_block(Gogo* gogo, Named_object* function, tree var_decl) tree block_tree = block_to_tree(bblock); if (block_tree == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(block_tree) == BIND_EXPR); + go_assert(TREE_CODE(block_tree) == BIND_EXPR); tree statements = BIND_EXPR_BODY(block_tree); while (statements != NULL_TREE && (TREE_CODE(statements) == TRY_FINALLY_EXPR @@ -1111,7 +1111,7 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no, tree id) { // The type of a function comes back as a pointer, but we // want the real function type for a function declaration. - gcc_assert(POINTER_TYPE_P(functype)); + go_assert(POINTER_TYPE_P(functype)); functype = TREE_TYPE(functype); tree decl = build_decl(this->location(), FUNCTION_DECL, id, functype); @@ -1225,7 +1225,7 @@ Function_declaration::get_or_make_decl(Gogo* gogo, Named_object* no, tree id) { // The type of a function comes back as a pointer, but we // want the real function type for a function declaration. - gcc_assert(POINTER_TYPE_P(functype)); + go_assert(POINTER_TYPE_P(functype)); functype = TREE_TYPE(functype); decl = build_decl(this->location(), FUNCTION_DECL, id, functype); TREE_PUBLIC(decl) = 1; @@ -1259,12 +1259,12 @@ Function::make_receiver_parm_decl(Gogo* gogo, Named_object* no, tree var_decl) { if (var_decl == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(var_decl) == VAR_DECL); + go_assert(TREE_CODE(var_decl) == VAR_DECL); tree val_type = TREE_TYPE(var_decl); bool is_in_heap = no->var_value()->is_in_heap(); if (is_in_heap) { - gcc_assert(POINTER_TYPE_P(val_type)); + go_assert(POINTER_TYPE_P(val_type)); val_type = TREE_TYPE(val_type); } @@ -1276,7 +1276,7 @@ Function::make_receiver_parm_decl(Gogo* gogo, Named_object* no, tree var_decl) DECL_CONTEXT(parm_decl) = current_function_decl; DECL_ARG_TYPE(parm_decl) = TREE_TYPE(parm_decl); - gcc_assert(DECL_INITIAL(var_decl) == NULL_TREE); + go_assert(DECL_INITIAL(var_decl) == NULL_TREE); // The receiver might be passed as a null pointer. tree check = fold_build2_loc(loc, NE_EXPR, boolean_type_node, parm_decl, fold_convert_loc(loc, TREE_TYPE(parm_decl), @@ -1324,7 +1324,7 @@ Function::copy_parm_to_heap(Gogo* gogo, Named_object* no, tree var_decl) { if (var_decl == error_mark_node) return error_mark_node; - gcc_assert(TREE_CODE(var_decl) == VAR_DECL); + go_assert(TREE_CODE(var_decl) == VAR_DECL); source_location loc = DECL_SOURCE_LOCATION(var_decl); std::string name = IDENTIFIER_POINTER(DECL_NAME(var_decl)); @@ -1332,7 +1332,7 @@ Function::copy_parm_to_heap(Gogo* gogo, Named_object* no, tree var_decl) tree id = get_identifier_from_string(name); tree type = TREE_TYPE(var_decl); - gcc_assert(POINTER_TYPE_P(type)); + go_assert(POINTER_TYPE_P(type)); type = TREE_TYPE(type); tree parm_decl = build_decl(loc, PARM_DECL, id, type); @@ -1359,7 +1359,7 @@ void Function::build_tree(Gogo* gogo, Named_object* named_function) { tree fndecl = this->fndecl_; - gcc_assert(fndecl != NULL_TREE); + go_assert(fndecl != NULL_TREE); tree params = NULL_TREE; tree* pp = ¶ms; @@ -1385,7 +1385,7 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) tree var = *pp; if (var != error_mark_node) { - gcc_assert(TREE_CODE(var) == VAR_DECL); + go_assert(TREE_CODE(var) == VAR_DECL); DECL_CHAIN(var) = declare_vars; declare_vars = var; } @@ -1399,7 +1399,7 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) tree var = *pp; if (var != error_mark_node) { - gcc_assert(TREE_CODE(var) == VAR_DECL); + go_assert(TREE_CODE(var) == VAR_DECL); DECL_CHAIN(var) = declare_vars; declare_vars = var; } @@ -1408,7 +1408,7 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) if (*pp != error_mark_node) { - gcc_assert(TREE_CODE(*pp) == PARM_DECL); + go_assert(TREE_CODE(*pp) == PARM_DECL); pp = &DECL_CHAIN(*pp); } } @@ -1447,7 +1447,7 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) if (var_decl != error_mark_node) { - gcc_assert(TREE_CODE(var_decl) == VAR_DECL); + go_assert(TREE_CODE(var_decl) == VAR_DECL); DECL_INITIAL(var_decl) = init; DECL_CHAIN(var_decl) = declare_vars; declare_vars = var_decl; @@ -1460,7 +1460,7 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) if (this->block_ != NULL) { - gcc_assert(DECL_INITIAL(fndecl) == NULL_TREE); + go_assert(DECL_INITIAL(fndecl) == NULL_TREE); // Declare variables if necessary. tree bind = NULL_TREE; @@ -1571,7 +1571,7 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function, tree ret_stmt = fold_build1_loc(end_loc, RETURN_EXPR, void_type_node, set); append_to_statement_list(ret_stmt, &stmt_list); - gcc_assert(*except == NULL_TREE); + go_assert(*except == NULL_TREE); *except = stmt_list; // Add some finally code to run the defer functions. This is used @@ -1623,7 +1623,7 @@ Function::build_defer_wrapper(Gogo* gogo, Named_object* named_function, append_to_statement_list(ret_stmt, &stmt_list); } - gcc_assert(*fini == NULL_TREE); + go_assert(*fini == NULL_TREE); *fini = stmt_list; } @@ -1640,10 +1640,10 @@ Function::return_value(Gogo* gogo, Named_object* named_function, if (results == NULL || results->empty()) return NULL_TREE; - gcc_assert(this->results_ != NULL); + go_assert(this->results_ != NULL); if (this->results_->size() != results->size()) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } @@ -1668,7 +1668,7 @@ Function::return_value(Gogo* gogo, Named_object* named_function, pr != results->end(); ++pr, ++index, field = DECL_CHAIN(field)) { - gcc_assert(field != NULL); + go_assert(field != NULL); Named_object* no = (*this->results_)[index]; Bvariable* bvar = no->get_backend_variable(gogo, named_function); tree val = var_to_tree(bvar); @@ -1893,7 +1893,7 @@ Gogo::go_string_constant_tree(const std::string& val) constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); tree field = TYPE_FIELDS(string_type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__data") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__data") == 0); elt->index = field; tree str = Gogo::string_constant_tree(val); elt->value = fold_convert(TREE_TYPE(field), @@ -1901,7 +1901,7 @@ Gogo::go_string_constant_tree(const std::string& val) elt = VEC_quick_push(constructor_elt, init, NULL); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__length") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__length") == 0); elt->index = field; elt->value = build_int_cst_type(TREE_TYPE(field), val.length()); @@ -1963,7 +1963,7 @@ Gogo::slice_type_tree(tree element_type_tree) tree Gogo::slice_element_type_tree(tree slice_type_tree) { - gcc_assert(TREE_CODE(slice_type_tree) == RECORD_TYPE + go_assert(TREE_CODE(slice_type_tree) == RECORD_TYPE && POINTER_TYPE_P(TREE_TYPE(TYPE_FIELDS(slice_type_tree)))); return TREE_TYPE(TREE_TYPE(TYPE_FIELDS(slice_type_tree))); } @@ -1977,15 +1977,15 @@ tree Gogo::slice_constructor(tree slice_type_tree, tree values, tree count, tree capacity) { - gcc_assert(TREE_CODE(slice_type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(slice_type_tree) == RECORD_TYPE); VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3); tree field = TYPE_FIELDS(slice_type_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); elt->index = field; - gcc_assert(TYPE_MAIN_VARIANT(TREE_TYPE(field)) + go_assert(TYPE_MAIN_VARIANT(TREE_TYPE(field)) == TYPE_MAIN_VARIANT(TREE_TYPE(values))); elt->value = values; @@ -1997,13 +1997,13 @@ Gogo::slice_constructor(tree slice_type_tree, tree values, tree count, } field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); elt = VEC_quick_push(constructor_elt, init, NULL); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), count); field = DECL_CHAIN(field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); elt = VEC_quick_push(constructor_elt, init, NULL); elt->index = field; elt->value = fold_convert(TREE_TYPE(field), capacity); @@ -2042,7 +2042,7 @@ Gogo::map_descriptor(Map_type* maptype) { if (p->second == error_mark_node) return error_mark_node; - gcc_assert(p->second != NULL_TREE && DECL_P(p->second)); + go_assert(p->second != NULL_TREE && DECL_P(p->second)); return build_fold_addr_expr(p->second); } @@ -2077,26 +2077,26 @@ Gogo::map_descriptor(Map_type* maptype) } tree map_entry_key_field = DECL_CHAIN(TYPE_FIELDS(map_entry_type)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_key_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_key_field)), "__key") == 0); tree map_entry_val_field = DECL_CHAIN(map_entry_key_field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_val_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_entry_val_field)), "__val") == 0); // Initialize the entries. tree map_descriptor_field = TYPE_FIELDS(struct_type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_descriptor_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(map_descriptor_field)), "__map_descriptor") == 0); tree entry_size_field = DECL_CHAIN(map_descriptor_field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(entry_size_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(entry_size_field)), "__entry_size") == 0); tree key_offset_field = DECL_CHAIN(entry_size_field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(key_offset_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(key_offset_field)), "__key_offset") == 0); tree val_offset_field = DECL_CHAIN(key_offset_field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(val_offset_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(val_offset_field)), "__val_offset") == 0); VEC(constructor_elt, gc)* descriptor = VEC_alloc(constructor_elt, gc, 6); @@ -2177,7 +2177,7 @@ Gogo::type_descriptor_decl_name(const Named_object* no, { std::string ret = "__go_tdn_"; if (no->type_value()->is_builtin()) - gcc_assert(in_function == NULL); + go_assert(in_function == NULL); else { const std::string& unique_prefix(no->package() == NULL @@ -2325,7 +2325,7 @@ Gogo::build_type_descriptor_decl(const Type* type, Expression* initializer, tree constructor = initializer->get_tree(&context); if (constructor == error_mark_node) - gcc_assert(saw_errors()); + go_assert(saw_errors()); DECL_INITIAL(decl) = constructor; @@ -2333,7 +2333,7 @@ Gogo::build_type_descriptor_decl(const Type* type, Expression* initializer, TREE_PUBLIC(decl) = 1; else { - gcc_assert(type_descriptor_location == TYPE_DESCRIPTOR_COMMON); + go_assert(type_descriptor_location == TYPE_DESCRIPTOR_COMMON); make_decl_one_only(decl, DECL_ASSEMBLER_NAME(decl)); resolve_unique_section(decl, 1, 0); } @@ -2351,7 +2351,7 @@ Gogo::interface_method_table_for_type(const Interface_type* interface, bool is_pointer) { const Typed_identifier_list* interface_methods = interface->methods(); - gcc_assert(!interface_methods->empty()); + go_assert(!interface_methods->empty()); std::string mangled_name = ((is_pointer ? "__go_pimt__" : "__go_imt_") + interface->mangled_name(this) @@ -2411,7 +2411,7 @@ Gogo::interface_method_table_for_type(const Interface_type* interface, { bool is_ambiguous; Method* m = type->method_function(p->name(), &is_ambiguous); - gcc_assert(m != NULL); + go_assert(m != NULL); Named_object* no = m->named_object(); @@ -2431,7 +2431,7 @@ Gogo::interface_method_table_for_type(const Interface_type* interface, elt->index = size_int(i); elt->value = fold_convert(const_ptr_type_node, fndecl); } - gcc_assert(i == count + 1); + go_assert(i == count + 1); tree array_type = build_array_type(const_ptr_type_node, build_index_type(size_int(count))); diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 94dcf6411a5..2ea6c5cf967 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -220,7 +220,7 @@ Gogo::message_name(const std::string& name) const std::string& Gogo::package_name() const { - gcc_assert(this->package_ != NULL); + go_assert(this->package_ != NULL); return this->package_->name(); } @@ -465,8 +465,8 @@ Gogo::lookup(const std::string& name, Named_object** pfunction) const Named_object* Gogo::lookup_in_block(const std::string& name) const { - gcc_assert(!this->functions_.empty()); - gcc_assert(!this->functions_.back().blocks.empty()); + go_assert(!this->functions_.empty()); + go_assert(!this->functions_.back().blocks.empty()); return this->functions_.back().blocks.back()->bindings()->lookup_local(name); } @@ -537,7 +537,7 @@ Named_object* Gogo::add_package(const std::string& real_name, const std::string& alias, const std::string& unique_prefix, source_location location) { - gcc_assert(this->in_global_scope()); + go_assert(this->in_global_scope()); // Register the package. Note that we might have already seen it in // an earlier import. @@ -555,7 +555,7 @@ Gogo::register_package(const std::string& package_name, const std::string& unique_prefix, source_location location) { - gcc_assert(!unique_prefix.empty() && !package_name.empty()); + go_assert(!unique_prefix.empty() && !package_name.empty()); std::string name = unique_prefix + '.' + package_name; Package* package = NULL; std::pair ins = @@ -564,8 +564,8 @@ Gogo::register_package(const std::string& package_name, { // We have seen this package name before. package = ins.first->second; - gcc_assert(package != NULL); - gcc_assert(package->name() == package_name + go_assert(package != NULL); + go_assert(package->name() == package_name && package->unique_prefix() == unique_prefix); if (package->location() == UNKNOWN_LOCATION) package->set_location(location); @@ -574,7 +574,7 @@ Gogo::register_package(const std::string& package_name, { // First time we have seen this package name. package = new Package(package_name, unique_prefix, location); - gcc_assert(ins.first->second == NULL); + go_assert(ins.first->second == NULL); ins.first->second = package; } @@ -707,7 +707,7 @@ Gogo::start_function(const std::string& name, Function_type* type, ret = Named_object::make_function(name, NULL, function); else { - gcc_assert(at_top_level); + go_assert(at_top_level); Type* rtype = type->receiver()->type(); // We want to look through the pointer created by the @@ -741,7 +741,7 @@ Gogo::start_function(const std::string& name, Function_type* type, Named_object* declared = this->declare_package_type(type_no->name(), type_no->location()); - gcc_assert(declared + go_assert(declared == type_no->unknown_value()->real_named_object()); } ret = rtype->forward_declaration_type()->add_method(name, @@ -773,7 +773,7 @@ void Gogo::finish_function(source_location location) { this->finish_block(location); - gcc_assert(this->functions_.back().blocks.empty()); + go_assert(this->functions_.back().blocks.empty()); this->functions_.pop_back(); } @@ -782,7 +782,7 @@ Gogo::finish_function(source_location location) Named_object* Gogo::current_function() const { - gcc_assert(!this->functions_.empty()); + go_assert(!this->functions_.empty()); return this->functions_.back().function; } @@ -791,7 +791,7 @@ Gogo::current_function() const void Gogo::start_block(source_location location) { - gcc_assert(!this->functions_.empty()); + go_assert(!this->functions_.empty()); Block* block = new Block(this->current_block(), location); this->functions_.back().blocks.push_back(block); } @@ -801,8 +801,8 @@ Gogo::start_block(source_location location) Block* Gogo::finish_block(source_location location) { - gcc_assert(!this->functions_.empty()); - gcc_assert(!this->functions_.back().blocks.empty()); + go_assert(!this->functions_.empty()); + go_assert(!this->functions_.back().blocks.empty()); Block* block = this->functions_.back().blocks.back(); this->functions_.back().blocks.pop_back(); block->set_end_location(location); @@ -859,7 +859,7 @@ Label* Gogo::add_label_definition(const std::string& label_name, source_location location) { - gcc_assert(!this->functions_.empty()); + go_assert(!this->functions_.empty()); Function* func = this->functions_.back().function->func_value(); Label* label = func->add_label_definition(label_name, location); this->add_statement(Statement::make_label_statement(label, location)); @@ -871,7 +871,7 @@ Gogo::add_label_definition(const std::string& label_name, Label* Gogo::add_label_reference(const std::string& label_name) { - gcc_assert(!this->functions_.empty()); + go_assert(!this->functions_.empty()); Function* func = this->functions_.back().function->func_value(); return func->add_label_reference(label_name); } @@ -881,7 +881,7 @@ Gogo::add_label_reference(const std::string& label_name) void Gogo::add_statement(Statement* statement) { - gcc_assert(!this->functions_.empty() + go_assert(!this->functions_.empty() && !this->functions_.back().blocks.empty()); this->functions_.back().blocks.back()->add_statement(statement); } @@ -891,7 +891,7 @@ Gogo::add_statement(Statement* statement) void Gogo::add_block(Block* block, source_location location) { - gcc_assert(!this->functions_.empty() + go_assert(!this->functions_.empty() && !this->functions_.back().blocks.empty()); Statement* statement = Statement::make_block_statement(block, location); this->functions_.back().blocks.back()->add_statement(statement); @@ -922,7 +922,7 @@ Gogo::add_type(const std::string& name, Type* type, source_location location) void Gogo::add_named_type(Named_type* type) { - gcc_assert(this->in_global_scope()); + go_assert(this->in_global_scope()); this->current_bindings()->add_named_type(type); } @@ -1206,7 +1206,7 @@ Lower_parse_tree::constant(Named_object* no, bool) return TRAVERSE_CONTINUE; nc->set_lowering(); - gcc_assert(this->iota_value_ == -1); + go_assert(this->iota_value_ == -1); this->iota_value_ = nc->iota_value(); nc->traverse_expression(this); this->iota_value_ = -1; @@ -1227,7 +1227,7 @@ Lower_parse_tree::function(Named_object* no) { no->func_value()->set_closure_type(); - gcc_assert(this->function_ == NULL); + go_assert(this->function_ == NULL); this->function_ = no; int t = no->func_value()->traverse(this); this->function_ = NULL; @@ -1324,7 +1324,7 @@ Gogo::lower_expression(Named_object* function, Expression** pexpr) void Gogo::lower_constant(Named_object* no) { - gcc_assert(no->is_const()); + go_assert(no->is_const()); Lower_parse_tree lower(this, NULL); lower.constant(no, false); } @@ -1644,7 +1644,7 @@ Find_shortcut::expression(Expression** pexpr) Operator op = be->op(); if (op != OPERATOR_OROR && op != OPERATOR_ANDAND) return TRAVERSE_CONTINUE; - gcc_assert(this->found_ == NULL); + go_assert(this->found_ == NULL); this->found_ = pexpr; return TRAVERSE_EXIT; } @@ -2173,7 +2173,7 @@ Build_recover_thunks::function(Named_object* orig_no) ++p) { Named_object* p_no = gogo->lookup(p->name(), NULL); - gcc_assert(p_no != NULL + go_assert(p_no != NULL && p_no->is_variable() && p_no->var_value()->is_parameter()); args->push_back(Expression::make_var_reference(p_no, location)); @@ -2217,7 +2217,7 @@ Build_recover_thunks::function(Named_object* orig_no) // We changed the receiver to be a regular parameter. We have // to update the binding accordingly in both functions. Named_object* orig_rec_no = orig_bindings->lookup_local(receiver_name); - gcc_assert(orig_rec_no != NULL + go_assert(orig_rec_no != NULL && orig_rec_no->is_variable() && !orig_rec_no->var_value()->is_receiver()); orig_rec_no->var_value()->set_is_receiver(); @@ -2225,10 +2225,10 @@ Build_recover_thunks::function(Named_object* orig_no) const std::string& new_receiver_name(orig_fntype->receiver()->name()); Named_object* new_rec_no = new_bindings->lookup_local(new_receiver_name); if (new_rec_no == NULL) - gcc_assert(saw_errors()); + go_assert(saw_errors()); else { - gcc_assert(new_rec_no->is_variable() + go_assert(new_rec_no->is_variable() && new_rec_no->var_value()->is_receiver()); new_rec_no->var_value()->set_is_not_receiver(); } @@ -2238,7 +2238,7 @@ Build_recover_thunks::function(Named_object* orig_no) // parameter appears in the (now) old bindings as a parameter. // Change it to a local variable, whereupon it will be discarded. Named_object* can_recover_no = orig_bindings->lookup_local(can_recover_name); - gcc_assert(can_recover_no != NULL + go_assert(can_recover_no != NULL && can_recover_no->is_variable() && can_recover_no->var_value()->is_parameter()); orig_bindings->remove_binding(can_recover_no); @@ -2488,7 +2488,7 @@ Gogo::check_return_statements() const std::string& Gogo::unique_prefix() const { - gcc_assert(!this->unique_prefix_.empty()); + go_assert(!this->unique_prefix_.empty()); return this->unique_prefix_; } @@ -2498,7 +2498,7 @@ Gogo::unique_prefix() const void Gogo::set_unique_prefix(const std::string& arg) { - gcc_assert(this->unique_prefix_.empty()); + go_assert(this->unique_prefix_.empty()); this->unique_prefix_ = arg; this->unique_prefix_specified_ = true; } @@ -2672,7 +2672,7 @@ Function::create_result_variables(Gogo* gogo) ++dummy_result_count; name = gogo->pack_hidden_name(buf, false); no = block->bindings()->add_result_variable(name, result); - gcc_assert(no->is_result_variable()); + go_assert(no->is_result_variable()); this->results_->push_back(no); } } @@ -2803,7 +2803,7 @@ Function::add_label_reference(const std::string& label_name) } else { - gcc_assert(ins.first->second == NULL); + go_assert(ins.first->second == NULL); Label* label = new Label(label_name); ins.first->second = label; label->set_is_used(); @@ -2834,13 +2834,13 @@ Function::check_labels() const void Function::swap_for_recover(Function *x) { - gcc_assert(this->enclosing_ == x->enclosing_); + go_assert(this->enclosing_ == x->enclosing_); std::swap(this->results_, x->results_); std::swap(this->closure_var_, x->closure_var_); std::swap(this->block_, x->block_); - gcc_assert(this->location_ == x->location_); - gcc_assert(this->fndecl_ == NULL && x->fndecl_ == NULL); - gcc_assert(this->defer_stack_ == NULL && x->defer_stack_ == NULL); + go_assert(this->location_ == x->location_); + go_assert(this->fndecl_ == NULL && x->fndecl_ == NULL); + go_assert(this->defer_stack_ == NULL && x->defer_stack_ == NULL); } // Traverse the tree. @@ -3032,7 +3032,7 @@ Function::import_func(Import* imp, std::string* pname, ptype, imp->location())); if (imp->peek_char() != ',') break; - gcc_assert(!*is_varargs); + go_assert(!*is_varargs); imp->require_c_string(", "); } } @@ -3105,7 +3105,7 @@ Block::add_statement_at_front(Statement* statement) void Block::replace_statement(size_t index, Statement* s) { - gcc_assert(index < this->statements_.size()); + go_assert(index < this->statements_.size()); this->statements_[index] = s; } @@ -3114,7 +3114,7 @@ Block::replace_statement(size_t index, Statement* s) void Block::insert_statement_before(size_t index, Statement* s) { - gcc_assert(index < this->statements_.size()); + go_assert(index < this->statements_.size()); this->statements_.insert(this->statements_.begin() + index, s); } @@ -3123,7 +3123,7 @@ Block::insert_statement_before(size_t index, Statement* s) void Block::insert_statement_after(size_t index, Statement* s) { - gcc_assert(index < this->statements_.size()); + go_assert(index < this->statements_.size()); this->statements_.insert(this->statements_.begin() + index + 1, s); } @@ -3340,8 +3340,8 @@ Variable::Variable(Type* type, Expression* init, bool is_global, type_from_range_value_(false), type_from_chan_element_(false), is_type_switch_var_(false), determined_type_(false) { - gcc_assert(type != NULL || init != NULL); - gcc_assert(!is_parameter || init == NULL); + go_assert(type != NULL || init != NULL); + go_assert(!is_parameter || init == NULL); } // Traverse the initializer expression. @@ -3390,7 +3390,7 @@ Variable::lower_init_expression(Gogo* gogo, Named_object* function) Block* Variable::preinit_block(Gogo* gogo) { - gcc_assert(this->is_global_); + go_assert(this->is_global_); if (this->preinit_ == NULL) this->preinit_ = new Block(NULL, this->location()); @@ -3519,7 +3519,7 @@ Variable::type() && this->type_->is_nil_constant_as_type()) { Type_guard_expression* tge = this->init_->type_guard_expression(); - gcc_assert(tge != NULL); + go_assert(tge != NULL); init = tge->expr(); type = NULL; } @@ -3546,9 +3546,9 @@ Variable::type() type = this->type_from_chan_element(init, false); else { - gcc_assert(init != NULL); + go_assert(init != NULL); type = init->type(); - gcc_assert(type != NULL); + go_assert(type != NULL); // Variables should not have abstract types. if (type->is_abstract()) @@ -3569,7 +3569,7 @@ Variable::type() Type* Variable::type() const { - gcc_assert(this->type_ != NULL); + go_assert(this->type_ != NULL); return this->type_; } @@ -3592,13 +3592,13 @@ Variable::determine_type() if (this->is_type_switch_var_ && this->type_->is_nil_constant_as_type()) { Type_guard_expression* tge = this->init_->type_guard_expression(); - gcc_assert(tge != NULL); + go_assert(tge != NULL); this->type_ = NULL; this->init_ = tge->expr(); } if (this->init_ == NULL) - gcc_assert(this->type_ != NULL && !this->type_->is_abstract()); + go_assert(this->type_ != NULL && !this->type_->is_abstract()); else if (this->type_from_init_tuple_) { Expression *init = this->init_; @@ -3628,7 +3628,7 @@ Variable::determine_type() if (this->type_ == NULL) { Type* type = this->init_->type(); - gcc_assert(type != NULL); + go_assert(type != NULL); if (type->is_abstract()) type = type->make_non_abstract_type(); @@ -3659,7 +3659,7 @@ Variable::determine_type() void Variable::export_var(Export* exp, const std::string& name) const { - gcc_assert(this->is_global_); + go_assert(this->is_global_); exp->write_c_string("var "); exp->write_string(name); exp->write_c_string(" "); @@ -3792,7 +3792,7 @@ Named_constant::determine_type() Type_context context(NULL, true); this->expr_->determine_type(&context); this->type_ = this->expr_->type(); - gcc_assert(this->type_ != NULL); + go_assert(this->type_ != NULL); } } @@ -3903,8 +3903,8 @@ Type_declaration::using_type() void Unknown_name::set_real_named_object(Named_object* no) { - gcc_assert(this->real_named_object_ == NULL); - gcc_assert(!no->is_unknown()); + go_assert(this->real_named_object_ == NULL); + go_assert(!no->is_unknown()); this->real_named_object_ = no; } @@ -3917,7 +3917,7 @@ Named_object::Named_object(const std::string& name, tree_(NULL) { if (Gogo::is_sink_name(name)) - gcc_assert(classification == NAMED_OBJECT_SINK); + go_assert(classification == NAMED_OBJECT_SINK); } // Make an unknown name. This is used by the parser. The name must @@ -4066,7 +4066,7 @@ Named_object::message_name() const void Named_object::set_type_value(Named_type* named_type) { - gcc_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); Type_declaration* td = this->u_.type_declaration; td->define_methods(named_type); Named_object* in_function = td->in_function(); @@ -4082,7 +4082,7 @@ Named_object::set_type_value(Named_type* named_type) void Named_object::set_function_value(Function* function) { - gcc_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); this->classification_ = NAMED_OBJECT_FUNC; // FIXME: We should free the old value. this->u_.func_value = function; @@ -4093,7 +4093,7 @@ Named_object::set_function_value(Function* function) void Named_object::declare_as_type() { - gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); + go_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); Unknown_name* unk = this->u_.unknown_value; this->classification_ = NAMED_OBJECT_TYPE_DECLARATION; this->u_.type_declaration = new Type_declaration(unk->location()); @@ -4268,7 +4268,7 @@ void Bindings::remove_binding(Named_object* no) { Contour::iterator pb = this->bindings_.find(no->name()); - gcc_assert(pb != this->bindings_.end()); + go_assert(pb != this->bindings_.end()); this->bindings_.erase(pb); for (std::vector::iterator pn = this->named_objects_.begin(); pn != this->named_objects_.end(); @@ -4300,9 +4300,9 @@ Named_object* Bindings::add_named_object_to_contour(Contour* contour, Named_object* named_object) { - gcc_assert(named_object == named_object->resolve()); + go_assert(named_object == named_object->resolve()); const std::string& name(named_object->name()); - gcc_assert(!Gogo::is_sink_name(name)); + go_assert(!Gogo::is_sink_name(name)); std::pair ins = contour->insert(std::make_pair(name, named_object)); @@ -4353,7 +4353,7 @@ Bindings::new_definition(Named_object* old_object, Named_object* new_object) Named_object* real = old_object->unknown_value()->real_named_object(); if (real != NULL) return this->new_definition(real, new_object); - gcc_assert(!new_object->is_unknown()); + go_assert(!new_object->is_unknown()); old_object->unknown_value()->set_real_named_object(new_object); if (!new_object->is_type_declaration() && !new_object->is_function_declaration()) @@ -4576,7 +4576,7 @@ Bindings::traverse(Traverse* traverse, bool is_global) case Named_object::NAMED_OBJECT_PACKAGE: // These are traversed in Gogo::traverse. - gcc_assert(is_global); + go_assert(is_global); break; case Named_object::NAMED_OBJECT_TYPE: @@ -4673,7 +4673,7 @@ Package::Package(const std::string& name, const std::string& unique_prefix, priority_(0), location_(location), used_(false), is_imported_(false), uses_sink_alias_(false) { - gcc_assert(!name.empty() && !unique_prefix.empty()); + go_assert(!name.empty() && !unique_prefix.empty()); } // Set the priority. We may see multiple priorities for an imported @@ -4723,7 +4723,7 @@ Traverse::remember_type(const Type* type) { if (type->is_error_type()) return true; - gcc_assert((this->traverse_mask() & traverse_types) != 0 + go_assert((this->traverse_mask() & traverse_types) != 0 || (this->traverse_mask() & traverse_expressions) != 0); // We only have to remember named types, as they are the only ones // we can see multiple times in a traversal. @@ -4741,7 +4741,7 @@ Traverse::remember_type(const Type* type) bool Traverse::remember_expression(const Expression* expression) { - gcc_assert((this->traverse_mask() & traverse_types) != 0 + go_assert((this->traverse_mask() & traverse_types) != 0 || (this->traverse_mask() & traverse_expressions) != 0); if (this->expressions_seen_ == NULL) this->expressions_seen_ = new Expressions_seen(); diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index f9eba50ec2e..788c80a454d 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -156,7 +156,7 @@ class Gogo static std::string hidden_name_prefix(const std::string& name) { - gcc_assert(Gogo::is_hidden_name(name)); + go_assert(Gogo::is_hidden_name(name)); return name.substr(1, name.rfind('.') - 1); } @@ -819,7 +819,7 @@ class Function void set_enclosing(Function* enclosing) { - gcc_assert(this->enclosing_ == NULL); + go_assert(this->enclosing_ == NULL); this->enclosing_ = enclosing; } @@ -865,7 +865,7 @@ class Function void set_closure_var(Named_object* v) { - gcc_assert(this->closure_var_ == NULL); + go_assert(this->closure_var_ == NULL); this->closure_var_ = v; } @@ -874,7 +874,7 @@ class Function Named_object* enclosing_var(unsigned int index) { - gcc_assert(index < this->closure_fields_.size()); + go_assert(index < this->closure_fields_.size()); return closure_fields_[index].first; } @@ -961,7 +961,7 @@ class Function tree get_decl() const { - gcc_assert(this->fndecl_ != NULL); + go_assert(this->fndecl_ != NULL); return this->fndecl_; } @@ -1147,7 +1147,7 @@ class Variable void set_is_receiver() { - gcc_assert(this->is_parameter_); + go_assert(this->is_parameter_); this->is_receiver_ = true; } @@ -1156,7 +1156,7 @@ class Variable void set_is_not_receiver() { - gcc_assert(this->is_parameter_); + go_assert(this->is_parameter_); this->is_receiver_ = false; } @@ -1184,7 +1184,7 @@ class Variable void set_is_varargs_parameter() { - gcc_assert(this->is_parameter_); + go_assert(this->is_parameter_); this->is_varargs_parameter_ = true; } @@ -1250,7 +1250,7 @@ class Variable void clear_type_from_chan_element() { - gcc_assert(this->type_from_chan_element_); + go_assert(this->type_from_chan_element_); this->type_from_chan_element_ = false; } @@ -1722,126 +1722,126 @@ class Named_object Unknown_name* unknown_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); + go_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); return this->u_.unknown_value; } const Unknown_name* unknown_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); + go_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); return this->u_.unknown_value; } Named_constant* const_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_CONST); + go_assert(this->classification_ == NAMED_OBJECT_CONST); return this->u_.const_value; } const Named_constant* const_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_CONST); + go_assert(this->classification_ == NAMED_OBJECT_CONST); return this->u_.const_value; } Named_type* type_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_TYPE); + go_assert(this->classification_ == NAMED_OBJECT_TYPE); return this->u_.type_value; } const Named_type* type_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_TYPE); + go_assert(this->classification_ == NAMED_OBJECT_TYPE); return this->u_.type_value; } Type_declaration* type_declaration_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); return this->u_.type_declaration; } const Type_declaration* type_declaration_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); return this->u_.type_declaration; } Variable* var_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_VAR); + go_assert(this->classification_ == NAMED_OBJECT_VAR); return this->u_.var_value; } const Variable* var_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_VAR); + go_assert(this->classification_ == NAMED_OBJECT_VAR); return this->u_.var_value; } Result_variable* result_var_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_RESULT_VAR); + go_assert(this->classification_ == NAMED_OBJECT_RESULT_VAR); return this->u_.result_var_value; } const Result_variable* result_var_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_RESULT_VAR); + go_assert(this->classification_ == NAMED_OBJECT_RESULT_VAR); return this->u_.result_var_value; } Function* func_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_FUNC); + go_assert(this->classification_ == NAMED_OBJECT_FUNC); return this->u_.func_value; } const Function* func_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_FUNC); + go_assert(this->classification_ == NAMED_OBJECT_FUNC); return this->u_.func_value; } Function_declaration* func_declaration_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); return this->u_.func_declaration_value; } const Function_declaration* func_declaration_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); + go_assert(this->classification_ == NAMED_OBJECT_FUNC_DECLARATION); return this->u_.func_declaration_value; } Package* package_value() { - gcc_assert(this->classification_ == NAMED_OBJECT_PACKAGE); + go_assert(this->classification_ == NAMED_OBJECT_PACKAGE); return this->u_.package_value; } const Package* package_value() const { - gcc_assert(this->classification_ == NAMED_OBJECT_PACKAGE); + go_assert(this->classification_ == NAMED_OBJECT_PACKAGE); return this->u_.package_value; } @@ -2174,7 +2174,7 @@ class Label void define(source_location location) { - gcc_assert(this->location_ == 0); + go_assert(this->location_ == 0); this->location_ = location; } @@ -2263,7 +2263,7 @@ class Package const std::string& unique_prefix() const { - gcc_assert(!this->unique_prefix_.empty()); + go_assert(!this->unique_prefix_.empty()); return this->unique_prefix_; } diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index d926edf4480..4aca1a3f9cb 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -456,7 +456,7 @@ Import::import_func(Package* package) if (rtype->is_error_type()) return NULL; Named_type* named_rtype = rtype->named_type(); - gcc_assert(named_rtype != NULL); + go_assert(named_rtype != NULL); no = named_rtype->add_method_declaration(name, package, fntype, loc); } else @@ -617,7 +617,7 @@ Import::read_type() return Type::make_error_type(); } else - gcc_assert(no->package() == package); + go_assert(no->package() == package); if (this->types_[index] == NULL) { @@ -628,7 +628,7 @@ Import::read_type() } else { - gcc_assert(no->is_type()); + go_assert(no->is_type()); this->types_[index] = no->type_value(); } } @@ -714,9 +714,9 @@ void Import::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) { Named_object* named_object = gogo->lookup_global(name); - gcc_assert(named_object != NULL && named_object->is_type()); + go_assert(named_object != NULL && named_object->is_type()); int index = - static_cast(code); - gcc_assert(index > 0 + go_assert(index > 0 && static_cast(index) < this->builtin_types_.size()); this->builtin_types_[index] = named_object->type_value(); } @@ -842,7 +842,7 @@ Stream_from_file::do_peek(size_t length, const char** bytes) return true; } // Don't bother to handle the general case, since we don't need it. - gcc_assert(length < 64); + go_assert(length < 64); char buf[64]; ssize_t got = read(this->fd_, buf, length); diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index 90b41ea2ed0..ce68582f945 100644 --- a/gcc/go/gofrontend/lex.cc +++ b/gcc/go/gofrontend/lex.cc @@ -132,9 +132,9 @@ Keywords::keyword_to_code(const char* keyword, size_t len) const const char* Keywords::keyword_to_string(Keyword code) const { - gcc_assert(code > KEYWORD_INVALID && code < this->count_); + go_assert(code > KEYWORD_INVALID && code < this->count_); const Mapping* map = &this->mapping_[code]; - gcc_assert(map->keycode == code); + go_assert(map->keycode == code); return map->keystring; } @@ -1005,7 +1005,7 @@ Lex::gather_number() std::string s(pnum, p - pnum); mpz_t val; int r = mpz_init_set_str(val, s.c_str(), base); - gcc_assert(r == 0); + go_assert(r == 0); if (neg) mpz_neg(val, val); @@ -1029,7 +1029,7 @@ Lex::gather_number() std::string s(pnum, p - pnum); mpz_t val; int r = mpz_init_set_str(val, s.c_str(), 10); - gcc_assert(r == 0); + go_assert(r == 0); if (neg) mpz_neg(val, val); @@ -1076,7 +1076,7 @@ Lex::gather_number() std::string s(pnum, p - pnum); mpfr_t val; int r = mpfr_init_set_str(val, s.c_str(), 10, GMP_RNDN); - gcc_assert(r == 0); + go_assert(r == 0); if (neg) mpfr_neg(val, val, GMP_RNDN); diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 4202ed3748c..bda07f1f8b0 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -183,7 +183,7 @@ class Token Keyword keyword() const { - gcc_assert(this->classification_ == TOKEN_KEYWORD); + go_assert(this->classification_ == TOKEN_KEYWORD); return this->u_.keyword; } @@ -196,7 +196,7 @@ class Token const std::string& identifier() const { - gcc_assert(this->classification_ == TOKEN_IDENTIFIER); + go_assert(this->classification_ == TOKEN_IDENTIFIER); return *this->u_.identifier_value.name; } @@ -204,7 +204,7 @@ class Token bool is_identifier_exported() const { - gcc_assert(this->classification_ == TOKEN_IDENTIFIER); + go_assert(this->classification_ == TOKEN_IDENTIFIER); return this->u_.identifier_value.is_exported; } @@ -220,7 +220,7 @@ class Token std::string string_value() const { - gcc_assert(this->classification_ == TOKEN_STRING); + go_assert(this->classification_ == TOKEN_STRING); return *this->u_.string_value; } @@ -228,7 +228,7 @@ class Token const mpz_t* integer_value() const { - gcc_assert(this->classification_ == TOKEN_INTEGER); + go_assert(this->classification_ == TOKEN_INTEGER); return &this->u_.integer_value; } @@ -236,7 +236,7 @@ class Token const mpfr_t* float_value() const { - gcc_assert(this->classification_ == TOKEN_FLOAT); + go_assert(this->classification_ == TOKEN_FLOAT); return &this->u_.float_value; } @@ -244,7 +244,7 @@ class Token const mpfr_t* imaginary_value() const { - gcc_assert(this->classification_ == TOKEN_IMAGINARY); + go_assert(this->classification_ == TOKEN_IMAGINARY); return &this->u_.float_value; } @@ -252,7 +252,7 @@ class Token Operator op() const { - gcc_assert(this->classification_ == TOKEN_OPERATOR); + go_assert(this->classification_ == TOKEN_OPERATOR); return this->u_.op; } diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index e5ea636b08a..b2a1715660f 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -85,7 +85,7 @@ Parse::advance_token() void Parse::unget_token(const Token& token) { - gcc_assert(!this->unget_token_valid_); + go_assert(!this->unget_token_valid_); this->unget_token_ = token; this->unget_token_valid_ = true; } @@ -372,7 +372,7 @@ Parse::type_name(bool issue_error) Type* Parse::array_type(bool may_use_ellipsis) { - gcc_assert(this->peek_token()->is_op(OPERATOR_LSQUARE)); + go_assert(this->peek_token()->is_op(OPERATOR_LSQUARE)); const Token* token = this->advance_token(); Expression* length = NULL; @@ -419,7 +419,7 @@ Type* Parse::map_type() { source_location location = this->location(); - gcc_assert(this->peek_token()->is_keyword(KEYWORD_MAP)); + go_assert(this->peek_token()->is_keyword(KEYWORD_MAP)); if (!this->advance_token()->is_op(OPERATOR_LSQUARE)) { error_at(this->location(), "expected %<[%>"); @@ -449,7 +449,7 @@ Parse::map_type() Type* Parse::struct_type() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_STRUCT)); + go_assert(this->peek_token()->is_keyword(KEYWORD_STRUCT)); source_location location = this->location(); if (!this->advance_token()->is_op(OPERATOR_LCURLY)) { @@ -618,7 +618,7 @@ Parse::field_decl(Struct_field_list* sfl) Type* Parse::pointer_type() { - gcc_assert(this->peek_token()->is_op(OPERATOR_MULT)); + go_assert(this->peek_token()->is_op(OPERATOR_MULT)); this->advance_token(); Type* type = this->type(); if (type->is_error_type()) @@ -649,7 +649,7 @@ Parse::channel_type() } else { - gcc_assert(token->is_keyword(KEYWORD_CHAN)); + go_assert(token->is_keyword(KEYWORD_CHAN)); if (this->advance_token()->is_op(OPERATOR_CHANOP)) { receive = false; @@ -870,7 +870,7 @@ Parse::parameter_list(bool* is_varargs) if (parameters_have_names) { - gcc_assert(!just_saw_comma); + go_assert(!just_saw_comma); // We have just seen ID1, ID2 xxx. Type* type; if (!this->peek_token()->is_op(OPERATOR_ELLIPSIS)) @@ -1119,7 +1119,7 @@ Parse::block() Type* Parse::interface_type() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_INTERFACE)); + go_assert(this->peek_token()->is_keyword(KEYWORD_INTERFACE)); source_location location = this->location(); if (!this->advance_token()->is_op(OPERATOR_LCURLY)) @@ -1307,7 +1307,7 @@ Parse::list(void (Parse::*pfn)(void*), void* varg, bool follow_is_paren) void Parse::const_decl() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_CONST)); + go_assert(this->peek_token()->is_keyword(KEYWORD_CONST)); this->advance_token(); this->reset_iota(); @@ -1408,7 +1408,7 @@ Parse::const_spec(Type** last_type, Expression_list** last_expr_list) void Parse::type_decl() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_TYPE)); + go_assert(this->peek_token()->is_keyword(KEYWORD_TYPE)); this->advance_token(); this->decl(&Parse::type_spec, NULL); } @@ -1473,7 +1473,7 @@ Parse::type_spec(void*) this->gogo_->define_type(named_type, Type::make_named_type(named_type, type, location)); - gcc_assert(named_type->package() == NULL); + go_assert(named_type->package() == NULL); } else { @@ -1488,7 +1488,7 @@ Parse::type_spec(void*) void Parse::var_decl() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_VAR)); + go_assert(this->peek_token()->is_keyword(KEYWORD_VAR)); this->advance_token(); this->decl(&Parse::var_spec, NULL); } @@ -1583,14 +1583,14 @@ Parse::init_vars(const Typed_identifier_list* til, Type* type, ++p) { if (init != NULL) - gcc_assert(pexpr != init->end()); + go_assert(pexpr != init->end()); this->init_var(*p, type, init == NULL ? NULL : *pexpr, is_coloneq, false, &any_new); if (init != NULL) ++pexpr; } if (init != NULL) - gcc_assert(pexpr == init->end()); + go_assert(pexpr == init->end()); if (is_coloneq && !any_new) error_at(location, "variables redeclared but no variable is new"); } @@ -1921,7 +1921,7 @@ Parse::simple_var_decl_or_assignment(const std::string& name, // "a, *p = 1, 2". if (this->peek_token()->is_op(OPERATOR_COMMA)) { - gcc_assert(p_type_switch == NULL); + go_assert(p_type_switch == NULL); while (true) { const Token* token = this->advance_token(); @@ -1979,7 +1979,7 @@ Parse::simple_var_decl_or_assignment(const std::string& name, } } - gcc_assert(this->peek_token()->is_op(OPERATOR_COLONEQ)); + go_assert(this->peek_token()->is_op(OPERATOR_COLONEQ)); const Token* token = this->advance_token(); if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE)) @@ -2032,7 +2032,7 @@ Parse::simple_var_decl_or_assignment(const std::string& name, void Parse::function_decl() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_FUNC)); + go_assert(this->peek_token()->is_keyword(KEYWORD_FUNC)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -2120,7 +2120,7 @@ Parse::function_decl() Typed_identifier* Parse::receiver() { - gcc_assert(this->peek_token()->is_op(OPERATOR_LPAREN)); + go_assert(this->peek_token()->is_op(OPERATOR_LPAREN)); std::string name; const Token* token = this->advance_token(); @@ -2249,7 +2249,7 @@ Parse::operand(bool may_be_sink) packed = this->gogo_->pack_hidden_name(id, is_exported); named_object = package->lookup(packed); location = this->location(); - gcc_assert(in_function == NULL); + go_assert(in_function == NULL); } this->advance_token(); @@ -2258,7 +2258,7 @@ Parse::operand(bool may_be_sink) && named_object->is_type() && !named_object->type_value()->is_visible()) { - gcc_assert(package != NULL); + go_assert(package != NULL); error_at(location, "invalid reference to hidden type %<%s.%s%>", Gogo::message_name(package->name()).c_str(), Gogo::message_name(id).c_str()); @@ -2411,7 +2411,7 @@ Expression* Parse::enclosing_var_reference(Named_object* in_function, Named_object* var, source_location location) { - gcc_assert(var->is_variable() || var->is_result_variable()); + go_assert(var->is_variable() || var->is_result_variable()); Named_object* this_function = this->gogo_->current_function(); Named_object* closure = this_function->func_value()->closure_var(); @@ -2459,7 +2459,7 @@ Parse::enclosing_var_reference(Named_object* in_function, Named_object* var, Expression* Parse::composite_lit(Type* type, int depth, source_location location) { - gcc_assert(this->peek_token()->is_op(OPERATOR_LCURLY)); + go_assert(this->peek_token()->is_op(OPERATOR_LCURLY)); this->advance_token(); if (this->peek_token()->is_op(OPERATOR_RCURLY)) @@ -2583,7 +2583,7 @@ Expression* Parse::function_lit() { source_location location = this->location(); - gcc_assert(this->peek_token()->is_keyword(KEYWORD_FUNC)); + go_assert(this->peek_token()->is_keyword(KEYWORD_FUNC)); this->advance_token(); Enclosing_vars hold_enclosing_vars; @@ -2653,7 +2653,7 @@ Parse::create_closure(Named_object* function, Enclosing_vars* enclosing_vars, Expression_list* initializer = new Expression_list; for (size_t i = 0; i < enclosing_var_count; ++i) { - gcc_assert(ev[i].index() == i); + go_assert(ev[i].index() == i); Named_object* var = ev[i].var(); Expression* ref; if (ev[i].in_function() == enclosing_function) @@ -2771,7 +2771,7 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit, Expression* Parse::selector(Expression* left, bool* is_type_switch) { - gcc_assert(this->peek_token()->is_op(OPERATOR_DOT)); + go_assert(this->peek_token()->is_op(OPERATOR_DOT)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -2831,7 +2831,7 @@ Expression* Parse::index(Expression* expr) { source_location location = this->location(); - gcc_assert(this->peek_token()->is_op(OPERATOR_LSQUARE)); + go_assert(this->peek_token()->is_op(OPERATOR_LSQUARE)); this->advance_token(); Expression* start; @@ -2867,7 +2867,7 @@ Parse::index(Expression* expr) Expression* Parse::call(Expression* func) { - gcc_assert(this->peek_token()->is_op(OPERATOR_LPAREN)); + go_assert(this->peek_token()->is_op(OPERATOR_LPAREN)); Expression_list* args = NULL; bool is_varargs = false; const Token* token = this->advance_token(); @@ -3469,7 +3469,7 @@ Parse::expression_stat(Expression* exp) void Parse::send_stmt(Expression* channel) { - gcc_assert(this->peek_token()->is_op(OPERATOR_CHANOP)); + go_assert(this->peek_token()->is_op(OPERATOR_CHANOP)); source_location loc = this->location(); this->advance_token(); Expression* val = this->expression(PRECEDENCE_NORMAL, false, true, NULL); @@ -3694,7 +3694,7 @@ Parse::tuple_assignment(Expression_list* lhs, Range_clause* p_range_clause) void Parse::go_or_defer_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_GO) + go_assert(this->peek_token()->is_keyword(KEYWORD_GO) || this->peek_token()->is_keyword(KEYWORD_DEFER)); bool is_go = this->peek_token()->is_keyword(KEYWORD_GO); source_location stat_location = this->location(); @@ -3726,7 +3726,7 @@ Parse::go_or_defer_stat() void Parse::return_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_RETURN)); + go_assert(this->peek_token()->is_keyword(KEYWORD_RETURN)); source_location location = this->location(); this->advance_token(); Expression_list* vals = NULL; @@ -3740,7 +3740,7 @@ Parse::return_stat() void Parse::if_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_IF)); + go_assert(this->peek_token()->is_keyword(KEYWORD_IF)); source_location location = this->location(); this->advance_token(); @@ -3830,7 +3830,7 @@ Parse::if_stat() void Parse::switch_stat(Label* label) { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_SWITCH)); + go_assert(this->peek_token()->is_keyword(KEYWORD_SWITCH)); source_location location = this->location(); this->advance_token(); @@ -4152,7 +4152,7 @@ Parse::type_case_clause(Named_object* switch_no, Type_case_clauses* clauses, if (is_default) { - gcc_assert(types.empty()); + go_assert(types.empty()); if (*saw_default) { error_at(location, "multiple defaults in type switch"); @@ -4212,7 +4212,7 @@ Parse::type_switch_case(std::vector* types, bool* is_default) void Parse::select_stat(Label* label) { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_SELECT)); + go_assert(this->peek_token()->is_keyword(KEYWORD_SELECT)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -4530,7 +4530,7 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, void Parse::for_stat(Label* label) { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_FOR)); + go_assert(this->peek_token()->is_keyword(KEYWORD_FOR)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -4650,7 +4650,7 @@ Parse::for_stat(Label* label) void Parse::for_clause(Expression** cond, Block** post) { - gcc_assert(this->peek_token()->is_op(OPERATOR_SEMICOLON)); + go_assert(this->peek_token()->is_op(OPERATOR_SEMICOLON)); this->advance_token(); if (this->peek_token()->is_op(OPERATOR_SEMICOLON)) *cond = NULL; @@ -4687,12 +4687,12 @@ void Parse::range_clause_decl(const Typed_identifier_list* til, Range_clause* p_range_clause) { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_RANGE)); + go_assert(this->peek_token()->is_keyword(KEYWORD_RANGE)); source_location location = this->location(); p_range_clause->found = true; - gcc_assert(til->size() >= 1); + go_assert(til->size() >= 1); if (til->size() > 2) error_at(this->location(), "too many variables for range clause"); @@ -4733,11 +4733,11 @@ void Parse::range_clause_expr(const Expression_list* vals, Range_clause* p_range_clause) { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_RANGE)); + go_assert(this->peek_token()->is_keyword(KEYWORD_RANGE)); p_range_clause->found = true; - gcc_assert(vals->size() >= 1); + go_assert(vals->size() >= 1); if (vals->size() > 2) error_at(this->location(), "too many variables for range clause"); @@ -4813,7 +4813,7 @@ Parse::find_bc_statement(const Bc_stack* bc_stack, const std::string& label) void Parse::break_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_BREAK)); + go_assert(this->peek_token()->is_keyword(KEYWORD_BREAK)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -4869,7 +4869,7 @@ Parse::break_stat() void Parse::continue_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_CONTINUE)); + go_assert(this->peek_token()->is_keyword(KEYWORD_CONTINUE)); source_location location = this->location(); const Token* token = this->advance_token(); @@ -4918,7 +4918,7 @@ Parse::continue_stat() void Parse::goto_stat() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_GOTO)); + go_assert(this->peek_token()->is_keyword(KEYWORD_GOTO)); source_location location = this->location(); const Token* token = this->advance_token(); if (!token->is_identifier()) @@ -4972,7 +4972,7 @@ Parse::package_clause() void Parse::import_decl() { - gcc_assert(this->peek_token()->is_keyword(KEYWORD_IMPORT)); + go_assert(this->peek_token()->is_keyword(KEYWORD_IMPORT)); this->advance_token(); this->decl(&Parse::import_spec, NULL); } diff --git a/gcc/go/gofrontend/runtime.cc b/gcc/go/gofrontend/runtime.cc index b10a1b63c7a..fe9b099eeaa 100644 --- a/gcc/go/gofrontend/runtime.cc +++ b/gcc/go/gofrontend/runtime.cc @@ -77,7 +77,7 @@ static Type* runtime_function_types[NUMBER_OF_RUNTIME_FUNCTION_TYPES]; static Type* runtime_function_type(Runtime_function_type bft) { - gcc_assert(bft < NUMBER_OF_RUNTIME_FUNCTION_TYPES); + go_assert(bft < NUMBER_OF_RUNTIME_FUNCTION_TYPES); if (runtime_function_types[bft] == NULL) { const source_location bloc = BUILTINS_LOCATION; @@ -223,7 +223,7 @@ convert_to_runtime_function_type(Runtime_function_type bft, Expression* e, return Expression::make_unsafe_cast(runtime_function_type(bft), e, loc); case RFT_TYPE: - gcc_assert(e->type() == Type::make_type_descriptor_ptr_type()); + go_assert(e->type() == Type::make_type_descriptor_ptr_type()); return e; } } @@ -240,7 +240,7 @@ Runtime::convert_types(Gogo* gogo) if (t != NULL && t->named_type() != NULL) { bool r = t->verify(); - gcc_assert(r); + go_assert(r); t->named_type()->convert(gogo); } } @@ -279,7 +279,7 @@ runtime_function_declarations[Runtime::NUMBER_OF_FUNCTIONS]; Named_object* Runtime::runtime_declaration(Function code) { - gcc_assert(code < Runtime::NUMBER_OF_FUNCTIONS); + go_assert(code < Runtime::NUMBER_OF_FUNCTIONS); if (runtime_function_declarations[code] == NULL) { const Runtime_function* pb = &runtime_functions[code]; @@ -339,11 +339,11 @@ Call_expression* Runtime::make_call(Runtime::Function code, source_location loc, int param_count, ...) { - gcc_assert(code < Runtime::NUMBER_OF_FUNCTIONS); + go_assert(code < Runtime::NUMBER_OF_FUNCTIONS); const Runtime_function* pb = &runtime_functions[code]; - gcc_assert(static_cast(param_count) + go_assert(static_cast(param_count) <= sizeof(pb->parameter_types) / sizeof(pb->parameter_types[0])); Named_object* no = runtime_declaration(code); diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 872dcb7b196..2fe02780aeb 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -230,7 +230,7 @@ Variable_declaration_statement::do_get_backend(Translate_context* context) if (!var->is_in_heap()) { - gcc_assert(binit != NULL); + go_assert(binit != NULL); return context->backend()->init_statement(bvar, binit); } @@ -239,7 +239,7 @@ Variable_declaration_statement::do_get_backend(Translate_context* context) // space, and assign the initial value to the new space. source_location loc = this->location(); Named_object* newfn = context->gogo()->lookup_global("new"); - gcc_assert(newfn != NULL && newfn->is_function_declaration()); + go_assert(newfn != NULL && newfn->is_function_declaration()); Expression* func = Expression::make_func_reference(newfn, NULL, loc); Expression_list* params = new Expression_list(); params->push_back(Expression::make_type(var->type(), loc)); @@ -335,7 +335,7 @@ Temporary_statement::do_determine_types() if (this->type_ == NULL) { this->type_ = this->init_->type(); - gcc_assert(!this->type_->is_abstract()); + go_assert(!this->type_->is_abstract()); } } @@ -364,7 +364,7 @@ Temporary_statement::do_check_types(Gogo*) Bstatement* Temporary_statement::do_get_backend(Translate_context* context) { - gcc_assert(this->bvariable_ == NULL); + go_assert(this->bvariable_ == NULL); // FIXME: Permitting FUNCTION to be NULL here is a temporary measure // until we have a better representation of the init function. @@ -406,7 +406,7 @@ Temporary_statement::get_backend_variable(Translate_context* context) const { if (this->bvariable_ == NULL) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return context->backend()->error_variable(); } return this->bvariable_; @@ -774,7 +774,7 @@ Tuple_assignment_statement::do_lower(Gogo*, Named_object*, Block* enclosing) plhs != this->lhs_->end(); ++plhs, ++prhs) { - gcc_assert(prhs != this->rhs_->end()); + go_assert(prhs != this->rhs_->end()); if ((*plhs)->is_error_expression() || (*plhs)->type()->is_error() @@ -794,7 +794,7 @@ Tuple_assignment_statement::do_lower(Gogo*, Named_object*, Block* enclosing) temps.push_back(temp); } - gcc_assert(prhs == this->rhs_->end()); + go_assert(prhs == this->rhs_->end()); prhs = this->rhs_->begin(); std::vector::const_iterator ptemp = temps.begin(); @@ -816,7 +816,7 @@ Tuple_assignment_statement::do_lower(Gogo*, Named_object*, Block* enclosing) b->add_statement(s); ++ptemp; } - gcc_assert(ptemp == temps.end()); + go_assert(ptemp == temps.end()); return Statement::make_block_statement(b, loc); } @@ -1709,7 +1709,7 @@ class Simplify_thunk_traverse : public Traverse int Simplify_thunk_traverse::function(Named_object* no) { - gcc_assert(this->function_ == NULL); + go_assert(this->function_ == NULL); this->function_ = no; int t = no->func_value()->traverse(this); this->function_ = NULL; @@ -1773,7 +1773,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function, Function_type* fntype = ce->get_function_type(); if (fntype == NULL) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); this->set_is_error(); return false; } @@ -1850,7 +1850,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function, // Look up the thunk. Named_object* named_thunk = gogo->lookup(thunk_name, NULL); - gcc_assert(named_thunk != NULL && named_thunk->is_function()); + go_assert(named_thunk != NULL && named_thunk->is_function()); // Build the call. Expression* func = Expression::make_func_reference(named_thunk, NULL, @@ -1869,8 +1869,8 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function, gcc_unreachable(); // The current block should end with the go statement. - gcc_assert(block->statements()->size() >= 1); - gcc_assert(block->statements()->back() == this); + go_assert(block->statements()->size() >= 1); + go_assert(block->statements()->back() == this); block->replace_statement(block->statements()->size() - 1, s); // We already ran the determine_types pass, so we need to run it now @@ -1934,7 +1934,7 @@ Thunk_statement::build_struct(Function_type* fntype) if (fn->bound_method_expression() != NULL) { - gcc_assert(fntype->is_method()); + go_assert(fntype->is_method()); Type* rtype = fntype->receiver()->type(); // We always pass the receiver as a pointer. if (rtype->points_to() == NULL) @@ -2043,7 +2043,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name, // Get a reference to the parameter. Named_object* named_parameter = gogo->lookup(parameter_name, NULL); - gcc_assert(named_parameter != NULL && named_parameter->is_variable()); + go_assert(named_parameter != NULL && named_parameter->is_variable()); // Build the call. Note that the field names are the same as the // ones used in build_struct. @@ -2066,7 +2066,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name, } else { - gcc_assert(bound_method == NULL && interface_method == NULL); + go_assert(bound_method == NULL && interface_method == NULL); func_to_call = ce->fn(); next_index = 0; } @@ -2111,7 +2111,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name, call_params->push_back(param); else { - gcc_assert(call_params->empty()); + go_assert(call_params->empty()); recover_arg = param; } } @@ -2176,7 +2176,7 @@ Thunk_statement::get_fn_and_arg(Expression** pfn, Expression** parg) *parg = Expression::make_nil(this->location()); else { - gcc_assert(args->size() == 1); + go_assert(args->size() == 1); *parg = args->front(); } @@ -2362,7 +2362,7 @@ Return_statement::do_lower(Gogo*, Named_object* function, Block* enclosing) i, reason.c_str()); } } - gcc_assert(lhs->size() == rhs->size()); + go_assert(lhs->size() == rhs->size()); if (lhs->empty()) ; @@ -2713,7 +2713,7 @@ If_statement::do_may_fall_through() const Bstatement* If_statement::do_get_backend(Translate_context* context) { - gcc_assert(this->cond_->type()->is_boolean_type() + go_assert(this->cond_->type()->is_boolean_type() || this->cond_->type()->is_error()); tree cond_tree = this->cond_->get_tree(context); Bexpression* cond_expr = tree_to_expr(cond_tree); @@ -2835,7 +2835,7 @@ Case_clauses::Case_clause::lower(Block* b, Temporary_statement* val_temp, Unnamed_label* next_case_label; if (this->cases_ == NULL || this->cases_->empty()) { - gcc_assert(this->is_default_); + go_assert(this->is_default_); next_case_label = NULL; } else @@ -2955,7 +2955,7 @@ Case_clauses::Case_clause::get_backend(Translate_context* context, { if (this->cases_ != NULL) { - gcc_assert(!this->is_default_); + go_assert(!this->is_default_); for (Expression_list::const_iterator p = this->cases_->begin(); p != this->cases_->end(); ++p) @@ -2970,10 +2970,10 @@ Case_clauses::Case_clause::get_backend(Translate_context* context, { // Something went wrong. This can happen with a // negative constant and an unsigned switch value. - gcc_assert(saw_errors()); + go_assert(saw_errors()); continue; } - gcc_assert(itype != NULL); + go_assert(itype != NULL); e = Expression::make_integer(&ival, itype, e->location()); mpz_clear(ival); } @@ -3434,7 +3434,7 @@ Type_case_clauses::Type_case_clause::lower(Block* b, else { // if COND { goto STMTS_LABEL } - gcc_assert(stmts_label != NULL); + go_assert(stmts_label != NULL); if (*stmts_label == NULL) *stmts_label = new Unnamed_label(UNKNOWN_LOCATION); dest = *stmts_label; @@ -3451,10 +3451,10 @@ Type_case_clauses::Type_case_clause::lower(Block* b, && stmts_label != NULL && *stmts_label != NULL)) { - gcc_assert(!this->is_fallthrough_); + go_assert(!this->is_fallthrough_); if (stmts_label != NULL && *stmts_label != NULL) { - gcc_assert(!this->is_default_); + go_assert(!this->is_default_); if (this->statements_ != NULL) (*stmts_label)->set_location(this->statements_->start_location()); Statement* s = Statement::make_unnamed_label_statement(*stmts_label); @@ -3467,7 +3467,7 @@ Type_case_clauses::Type_case_clause::lower(Block* b, } if (this->is_fallthrough_) - gcc_assert(next_case_label == NULL); + go_assert(next_case_label == NULL); else { source_location gloc = (this->statements_ == NULL @@ -3548,7 +3548,7 @@ Type_case_clauses::lower(Block* b, Temporary_statement* descriptor_temp, default_case = &*p; } } - gcc_assert(stmts_label == NULL); + go_assert(stmts_label == NULL); if (default_case != NULL) default_case->lower(b, descriptor_temp, break_label, NULL); @@ -3770,7 +3770,7 @@ Send_statement::do_get_backend(Translate_context* context) case Type::TYPE_NIL: case Type::TYPE_NAMED: case Type::TYPE_FORWARD: - gcc_assert(saw_errors()); + go_assert(saw_errors()); return context->backend()->error_statement(); } @@ -3879,7 +3879,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, { if (this->is_default_) { - gcc_assert(this->channel_ == NULL && this->val_ == NULL); + go_assert(this->channel_ == NULL && this->val_ == NULL); this->is_lowered_ = true; return; } @@ -3918,7 +3918,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, } else if (this->closed_ != NULL && !this->closed_->is_sink_expression()) { - gcc_assert(this->var_ == NULL && this->closedvar_ == NULL); + go_assert(this->var_ == NULL && this->closedvar_ == NULL); if (this->val_ == NULL) this->val_ = Expression::make_sink(loc); Statement* s = Statement::make_tuple_receive_assignment(this->val_, @@ -3928,7 +3928,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, } else if (this->closedvar_ != NULL) { - gcc_assert(this->val_ == NULL); + go_assert(this->val_ == NULL); Expression* val; if (this->var_ == NULL) val = Expression::make_sink(loc); @@ -3940,7 +3940,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, true, loc); // We have to put S in STATEMENTS_, because that is where the // variables are declared. - gcc_assert(this->statements_ != NULL); + go_assert(this->statements_ != NULL); this->statements_->add_statement_at_front(s); // We have to lower STATEMENTS_ again, to lower the tuple // receive assignment we just added. @@ -3952,7 +3952,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, recv->set_for_select(); if (this->val_ != NULL) { - gcc_assert(this->var_ == NULL); + go_assert(this->var_ == NULL); init->add_statement(Statement::make_assignment(this->val_, recv, loc)); } @@ -3988,7 +3988,7 @@ Select_clauses::Select_clause::lower(Gogo* gogo, Named_object* function, void Select_clauses::Select_clause::determine_types() { - gcc_assert(this->is_lowered_); + go_assert(this->is_lowered_); if (this->statements_ != NULL) this->statements_->determine_types(); } @@ -4118,7 +4118,7 @@ Select_clauses::get_backend(Translate_context* context, { // We should have given an error in the send or receive // statement we created via lowering. - gcc_assert(saw_errors()); + go_assert(saw_errors()); return context->backend()->error_statement(); } @@ -4132,7 +4132,7 @@ Select_clauses::get_backend(Translate_context* context, if (chan_init->empty()) { - gcc_assert(count == 0); + go_assert(count == 0); Bstatement* s; Bstatement* ldef = break_label->get_definition(context); if (default_clause != NULL) @@ -4162,7 +4162,7 @@ Select_clauses::get_backend(Translate_context* context, return ldef; return context->backend()->compound_statement(s, ldef); } - gcc_assert(count > 0); + go_assert(count > 0); std::vector statements; @@ -4458,7 +4458,7 @@ void For_statement::set_break_continue_labels(Unnamed_label* break_label, Unnamed_label* continue_label) { - gcc_assert(this->break_label_ == NULL && this->continue_label_ == NULL); + go_assert(this->break_label_ == NULL && this->continue_label_ == NULL); this->break_label_ = break_label; this->continue_label_ = continue_label; } @@ -4659,7 +4659,7 @@ For_range_statement::call_builtin(Gogo* gogo, const char* funcname, source_location loc) { Named_object* no = gogo->lookup_global(funcname); - gcc_assert(no != NULL && no->is_function_declaration()); + go_assert(no != NULL && no->is_function_declaration()); Expression* func = Expression::make_func_reference(no, NULL, loc); Expression_list* params = new Expression_list(); params->push_back(arg); @@ -4990,7 +4990,7 @@ For_range_statement::lower_range_channel(Gogo*, Block** piter_init, Block** ppost) { - gcc_assert(value_temp == NULL); + go_assert(value_temp == NULL); source_location loc = this->location(); diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h index ebdeb2d4170..7f6401b0313 100644 --- a/gcc/go/gofrontend/statements.h +++ b/gcc/go/gofrontend/statements.h @@ -690,7 +690,7 @@ class Select_clauses : channel_(channel), val_(val), closed_(closed), var_(var), closedvar_(closedvar), statements_(statements), location_(location), is_send_(is_send), is_default_(is_default), is_lowered_(false) - { gcc_assert(is_default ? channel == NULL : channel != NULL); } + { go_assert(is_default ? channel == NULL : channel != NULL); } // Traverse the select clause. int @@ -719,7 +719,7 @@ class Select_clauses bool is_send() const { - gcc_assert(!this->is_default_); + go_assert(!this->is_default_); return this->is_send_; } @@ -792,7 +792,7 @@ class Select_statement : public Statement void add_clauses(Select_clauses* clauses) { - gcc_assert(this->clauses_ == NULL); + go_assert(this->clauses_ == NULL); this->clauses_ = clauses; } @@ -967,7 +967,7 @@ class For_statement : public Statement void add_statements(Block* statements) { - gcc_assert(this->statements_ == NULL); + go_assert(this->statements_ == NULL); this->statements_ = statements; } @@ -1030,7 +1030,7 @@ class For_range_statement : public Statement void add_statements(Block* statements) { - gcc_assert(this->statements_ == NULL); + go_assert(this->statements_ == NULL); this->statements_ = statements; } @@ -1267,7 +1267,7 @@ class Switch_statement : public Statement void add_clauses(Case_clauses* clauses) { - gcc_assert(this->clauses_ == NULL); + go_assert(this->clauses_ == NULL); this->clauses_ = clauses; } @@ -1407,13 +1407,13 @@ class Type_switch_statement : public Statement source_location location) : Statement(STATEMENT_TYPE_SWITCH, location), var_(var), expr_(expr), clauses_(NULL), break_label_(NULL) - { gcc_assert(var == NULL || expr == NULL); } + { go_assert(var == NULL || expr == NULL); } // Add the clauses. void add_clauses(Type_case_clauses* clauses) { - gcc_assert(this->clauses_ == NULL); + go_assert(this->clauses_ == NULL); this->clauses_ = clauses; } diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index da22947cb21..0107c15bf8d 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -188,7 +188,7 @@ Type::is_abstract() const Type* Type::make_non_abstract_type() { - gcc_assert(this->is_abstract()); + go_assert(this->is_abstract()); switch (this->classification()) { case TYPE_INTEGER: @@ -270,7 +270,7 @@ Type::is_nil_constant_as_type() const int Type::traverse(Type* type, Traverse* traverse) { - gcc_assert((traverse->traverse_mask() & Traverse::traverse_types) != 0 + go_assert((traverse->traverse_mask() & Traverse::traverse_types) != 0 || (traverse->traverse_mask() & Traverse::traverse_expressions) != 0); if (traverse->remember_type(type)) @@ -942,7 +942,7 @@ Type::type_descriptor_pointer(Gogo* gogo) { Expression* e = t->do_type_descriptor(gogo, NULL); gogo->build_type_descriptor_decl(t, e, &t->type_descriptor_decl_); - gcc_assert(t->type_descriptor_decl_ != NULL_TREE + go_assert(t->type_descriptor_decl_ != NULL_TREE && (t->type_descriptor_decl_ == error_mark_node || DECL_P(t->type_descriptor_decl_))); } @@ -964,7 +964,7 @@ Type::type_descriptor(Gogo* gogo, Type* type) Expression* Type::named_type_descriptor(Gogo* gogo, Type* type, Named_type* name) { - gcc_assert(name != NULL && type->named_type() != name); + go_assert(name != NULL && type->named_type() != name); return type->do_type_descriptor(gogo, name); } @@ -1018,7 +1018,7 @@ Type::convert_builtin_named_types(Gogo* gogo) ++p) { bool r = (*p)->verify(); - gcc_assert(r); + go_assert(r); (*p)->convert(gogo); } } @@ -1218,28 +1218,28 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, vals->reserve(9); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "Kind"); + go_assert(p->field_name() == "Kind"); mpz_t iv; mpz_init_set_ui(iv, runtime_type_kind); vals->push_back(Expression::make_integer(&iv, p->type(), bloc)); ++p; - gcc_assert(p->field_name() == "align"); + go_assert(p->field_name() == "align"); Expression::Type_info type_info = Expression::TYPE_INFO_ALIGNMENT; vals->push_back(Expression::make_type_info(this, type_info)); ++p; - gcc_assert(p->field_name() == "fieldAlign"); + go_assert(p->field_name() == "fieldAlign"); type_info = Expression::TYPE_INFO_FIELD_ALIGNMENT; vals->push_back(Expression::make_type_info(this, type_info)); ++p; - gcc_assert(p->field_name() == "size"); + go_assert(p->field_name() == "size"); type_info = Expression::TYPE_INFO_SIZE; vals->push_back(Expression::make_type_info(this, type_info)); ++p; - gcc_assert(p->field_name() == "hash"); + go_assert(p->field_name() == "hash"); mpz_set_ui(iv, this->hash_for_method(gogo)); vals->push_back(Expression::make_integer(&iv, p->type(), bloc)); @@ -1248,7 +1248,7 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, this->type_functions(&hash_fn, &equal_fn); ++p; - gcc_assert(p->field_name() == "hashfn"); + go_assert(p->field_name() == "hashfn"); Function_type* fntype = p->type()->function_type(); Named_object* no = Named_object::make_function_declaration(hash_fn, NULL, fntype, @@ -1257,14 +1257,14 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, vals->push_back(Expression::make_func_reference(no, NULL, bloc)); ++p; - gcc_assert(p->field_name() == "equalfn"); + go_assert(p->field_name() == "equalfn"); fntype = p->type()->function_type(); no = Named_object::make_function_declaration(equal_fn, NULL, fntype, bloc); no->func_declaration_value()->set_asm_name(equal_fn); vals->push_back(Expression::make_func_reference(no, NULL, bloc)); ++p; - gcc_assert(p->field_name() == "string"); + go_assert(p->field_name() == "string"); Expression* s = Expression::make_string((name != NULL ? name->reflection(gogo) : this->reflection(gogo)), @@ -1272,7 +1272,7 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, vals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); ++p; - gcc_assert(p->field_name() == "uncommonType"); + go_assert(p->field_name() == "uncommonType"); if (name == NULL && methods == NULL) vals->push_back(Expression::make_nil(bloc)); else @@ -1286,7 +1286,7 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, } ++p; - gcc_assert(p->field_name() == "ptrToThis"); + go_assert(p->field_name() == "ptrToThis"); if (name == NULL) vals->push_back(Expression::make_nil(bloc)); else @@ -1296,7 +1296,7 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind, } ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); mpz_clear(iv); @@ -1323,10 +1323,10 @@ Type::uncommon_type_constructor(Gogo* gogo, Type* uncommon_type, vals->reserve(3); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "name"); + go_assert(p->field_name() == "name"); ++p; - gcc_assert(p->field_name() == "pkgPath"); + go_assert(p->field_name() == "pkgPath"); if (name == NULL) { @@ -1365,12 +1365,12 @@ Type::uncommon_type_constructor(Gogo* gogo, Type* uncommon_type, } ++p; - gcc_assert(p->field_name() == "methods"); + go_assert(p->field_name() == "methods"); vals->push_back(this->methods_constructor(gogo, p->type(), methods, only_value_methods)); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); Expression* r = Expression::make_struct_composite_literal(uncommon_type, vals, bloc); @@ -1452,13 +1452,13 @@ Type::method_constructor(Gogo*, Type* method_type, vals->reserve(5); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "name"); + go_assert(p->field_name() == "name"); const std::string n = Gogo::unpack_hidden_name(method_name); Expression* s = Expression::make_string(n, bloc); vals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); ++p; - gcc_assert(p->field_name() == "pkgPath"); + go_assert(p->field_name() == "pkgPath"); if (!Gogo::is_hidden_name(method_name)) vals->push_back(Expression::make_nil(bloc)); else @@ -1476,23 +1476,23 @@ Type::method_constructor(Gogo*, Type* method_type, mtype = no->func_value()->type(); else mtype = no->func_declaration_value()->type(); - gcc_assert(mtype->is_method()); + go_assert(mtype->is_method()); Type* nonmethod_type = mtype->copy_without_receiver(); ++p; - gcc_assert(p->field_name() == "mtyp"); + go_assert(p->field_name() == "mtyp"); vals->push_back(Expression::make_type_descriptor(nonmethod_type, bloc)); ++p; - gcc_assert(p->field_name() == "typ"); + go_assert(p->field_name() == "typ"); vals->push_back(Expression::make_type_descriptor(mtype, bloc)); ++p; - gcc_assert(p->field_name() == "tfn"); + go_assert(p->field_name() == "tfn"); vals->push_back(Expression::make_func_reference(no, NULL, bloc)); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(method_type, vals, bloc); } @@ -1597,7 +1597,7 @@ class Error_type : public Type void do_reflection(Gogo*, std::string*) const - { gcc_assert(saw_errors()); } + { go_assert(saw_errors()); } void do_mangled_name(Gogo*, std::string* ret) const @@ -1690,7 +1690,7 @@ Boolean_type::do_type_descriptor(Gogo* gogo, Named_type* name) else { Named_object* no = gogo->lookup_global("bool"); - gcc_assert(no != NULL); + go_assert(no != NULL); return Type::type_descriptor(gogo, no->type_value()); } } @@ -1748,7 +1748,7 @@ Integer_type::create_integer_type(const char* name, bool is_unsigned, Named_type* named_type = named_object->type_value(); std::pair ins = Integer_type::named_integer_types.insert(std::make_pair(sname, named_type)); - gcc_assert(ins.second); + go_assert(ins.second); return named_type; } @@ -1759,7 +1759,7 @@ Integer_type::lookup_integer_type(const char* name) { Named_integer_types::const_iterator p = Integer_type::named_integer_types.find(name); - gcc_assert(p != Integer_type::named_integer_types.end()); + go_assert(p != Integer_type::named_integer_types.end()); return p->second; } @@ -1802,7 +1802,7 @@ Integer_type::do_get_tree(Gogo*) { if (this->is_abstract_) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } @@ -1850,7 +1850,7 @@ Integer_type::do_get_init_tree(Gogo*, tree type_tree, bool is_clear) Expression* Integer_type::do_type_descriptor(Gogo* gogo, Named_type* name) { - gcc_assert(name != NULL); + go_assert(name != NULL); return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name); } @@ -1859,7 +1859,7 @@ Integer_type::do_type_descriptor(Gogo* gogo, Named_type* name) void Integer_type::do_reflection(Gogo*, std::string*) const { - gcc_assert(saw_errors()); + go_assert(saw_errors()); } // Mangled name. @@ -1919,7 +1919,7 @@ Float_type::create_float_type(const char* name, int bits, Named_type* named_type = named_object->type_value(); std::pair ins = Float_type::named_float_types.insert(std::make_pair(sname, named_type)); - gcc_assert(ins.second); + go_assert(ins.second); return named_type; } @@ -1930,7 +1930,7 @@ Float_type::lookup_float_type(const char* name) { Named_float_types::const_iterator p = Float_type::named_float_types.find(name); - gcc_assert(p != Float_type::named_float_types.end()); + go_assert(p != Float_type::named_float_types.end()); return p->second; } @@ -2006,7 +2006,7 @@ Float_type::do_get_init_tree(Gogo*, tree type_tree, bool is_clear) Expression* Float_type::do_type_descriptor(Gogo* gogo, Named_type* name) { - gcc_assert(name != NULL); + go_assert(name != NULL); return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name); } @@ -2015,7 +2015,7 @@ Float_type::do_type_descriptor(Gogo* gogo, Named_type* name) void Float_type::do_reflection(Gogo*, std::string*) const { - gcc_assert(saw_errors()); + go_assert(saw_errors()); } // Mangled name. @@ -2075,7 +2075,7 @@ Complex_type::create_complex_type(const char* name, int bits, std::pair ins = Complex_type::named_complex_types.insert(std::make_pair(sname, named_type)); - gcc_assert(ins.second); + go_assert(ins.second); return named_type; } @@ -2086,7 +2086,7 @@ Complex_type::lookup_complex_type(const char* name) { Named_complex_types::const_iterator p = Complex_type::named_complex_types.find(name); - gcc_assert(p != Complex_type::named_complex_types.end()); + go_assert(p != Complex_type::named_complex_types.end()); return p->second; } @@ -2166,7 +2166,7 @@ Complex_type::do_get_init_tree(Gogo*, tree type_tree, bool is_clear) Expression* Complex_type::do_type_descriptor(Gogo* gogo, Named_type* name) { - gcc_assert(name != NULL); + go_assert(name != NULL); return this->plain_type_descriptor(gogo, this->runtime_type_kind_, name); } @@ -2175,7 +2175,7 @@ Complex_type::do_type_descriptor(Gogo* gogo, Named_type* name) void Complex_type::do_reflection(Gogo*, std::string*) const { - gcc_assert(saw_errors()); + go_assert(saw_errors()); } // Mangled name. @@ -2236,9 +2236,9 @@ tree String_type::length_tree(Gogo*, tree string) { tree string_type = TREE_TYPE(string); - gcc_assert(TREE_CODE(string_type) == RECORD_TYPE); + go_assert(TREE_CODE(string_type) == RECORD_TYPE); tree length_field = DECL_CHAIN(TYPE_FIELDS(string_type)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(length_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(length_field)), "__length") == 0); return fold_build3(COMPONENT_REF, integer_type_node, string, length_field, NULL_TREE); @@ -2250,9 +2250,9 @@ tree String_type::bytes_tree(Gogo*, tree string) { tree string_type = TREE_TYPE(string); - gcc_assert(TREE_CODE(string_type) == RECORD_TYPE); + go_assert(TREE_CODE(string_type) == RECORD_TYPE); tree bytes_field = TYPE_FIELDS(string_type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(bytes_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(bytes_field)), "__data") == 0); return fold_build3(COMPONENT_REF, TREE_TYPE(bytes_field), string, bytes_field, NULL_TREE); @@ -2266,7 +2266,7 @@ String_type::do_get_init_tree(Gogo*, tree type_tree, bool is_clear) if (is_clear) return NULL_TREE; - gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(type_tree) == RECORD_TYPE); VEC(constructor_elt, gc)* init = VEC_alloc(constructor_elt, gc, 2); @@ -2294,7 +2294,7 @@ String_type::do_type_descriptor(Gogo* gogo, Named_type* name) else { Named_object* no = gogo->lookup_global("string"); - gcc_assert(no != NULL); + go_assert(no != NULL); return Type::type_descriptor(gogo, no->type_value()); } } @@ -2780,27 +2780,27 @@ Function_type::do_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(4); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_FUNC, name, NULL, true)); ++p; - gcc_assert(p->field_name() == "dotdotdot"); + go_assert(p->field_name() == "dotdotdot"); vals->push_back(Expression::make_boolean(this->is_varargs(), bloc)); ++p; - gcc_assert(p->field_name() == "in"); + go_assert(p->field_name() == "in"); vals->push_back(this->type_descriptor_params(p->type(), this->receiver(), this->parameters())); ++p; - gcc_assert(p->field_name() == "out"); + go_assert(p->field_name() == "out"); vals->push_back(this->type_descriptor_params(p->type(), NULL, this->results())); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(ftdt, vals, bloc); } @@ -2850,7 +2850,7 @@ Function_type::do_reflection(Gogo* gogo, std::string* ret) const { // FIXME: Turn this off until we straighten out the type of the // struct field used in a go statement which calls a method. - // gcc_assert(this->receiver_ == NULL); + // go_assert(this->receiver_ == NULL); ret->append("func"); @@ -3032,7 +3032,7 @@ Function_type::do_import(Import* imp) ptype, imp->location())); if (imp->peek_char() != ',') break; - gcc_assert(!is_varargs); + go_assert(!is_varargs); imp->require_c_string(", "); } } @@ -3079,7 +3079,7 @@ Function_type::do_import(Import* imp) Function_type* Function_type::copy_without_receiver() const { - gcc_assert(this->is_method()); + go_assert(this->is_method()); Function_type *ret = Type::make_function_type(NULL, this->parameters_, this->results_, this->location_); @@ -3095,7 +3095,7 @@ Function_type::copy_without_receiver() const Function_type* Function_type::copy_with_receiver(Type* receiver_type) const { - gcc_assert(!this->is_method()); + go_assert(!this->is_method()); Typed_identifier* receiver = new Typed_identifier("", receiver_type, this->location_); return Type::make_function_type(receiver, this->parameters_, @@ -3177,7 +3177,7 @@ Pointer_type::do_type_descriptor(Gogo* gogo, Named_type* name) { if (this->is_unsafe_pointer_type()) { - gcc_assert(name != NULL); + go_assert(name != NULL); return this->plain_type_descriptor(gogo, RUNTIME_TYPE_KIND_UNSAFE_POINTER, name); @@ -3203,13 +3203,13 @@ Pointer_type::do_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(2); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_PTR, name, methods, false)); ++p; - gcc_assert(p->field_name() == "elem"); + go_assert(p->field_name() == "elem"); vals->push_back(Expression::make_type_descriptor(deref, bloc)); return Expression::make_struct_composite_literal(ptr_tdt, vals, bloc); @@ -3335,7 +3335,7 @@ class Call_multiple_result_type : public Type bool do_has_pointer() const { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return false; } @@ -3345,24 +3345,24 @@ class Call_multiple_result_type : public Type tree do_get_init_tree(Gogo*, tree, bool) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } Expression* do_type_descriptor(Gogo*, Named_type*) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return Expression::make_error(UNKNOWN_LOCATION); } void do_reflection(Gogo*, std::string*) const - { gcc_assert(saw_errors()); } + { go_assert(saw_errors()); } void do_mangled_name(Gogo*, std::string*) const - { gcc_assert(saw_errors()); } + { go_assert(saw_errors()); } private: // The expression being called. @@ -3375,9 +3375,9 @@ tree Call_multiple_result_type::do_get_tree(Gogo* gogo) { Function_type* fntype = this->call_->get_function_type(); - gcc_assert(fntype != NULL); + go_assert(fntype != NULL); const Typed_identifier_list* results = fntype->results(); - gcc_assert(results != NULL && results->size() > 1); + go_assert(results != NULL && results->size() > 1); tree fntype_tree = fntype->get_tree(gogo); if (fntype_tree == error_mark_node) return error_mark_node; @@ -3428,7 +3428,7 @@ Struct_field::field_name() const { // Avoid crashing in the erroneous case where T is named but // DT is not. - gcc_assert(t != dt); + go_assert(t != dt); if (t->forward_declaration_type() != NULL) return t->forward_declaration_type()->name(); else if (t->named_type() != NULL) @@ -3748,7 +3748,7 @@ Struct_type::field_reference_depth(Expression* struct_expr, while (sub->expr() != NULL) { sub = sub->expr()->deref()->field_reference_expression(); - gcc_assert(sub != NULL); + go_assert(sub != NULL); } sub->set_struct_expression(here); } @@ -3859,7 +3859,7 @@ Struct_type::fill_in_tree(Gogo* gogo, tree type) tree field_type_tree = p->type()->get_tree(gogo); if (field_type_tree == error_mark_node) return error_mark_node; - gcc_assert(TYPE_SIZE(field_type_tree) != NULL_TREE); + go_assert(TYPE_SIZE(field_type_tree) != NULL_TREE); tree field = build_decl(p->location(), FIELD_DECL, name_tree, field_type_tree); @@ -3906,7 +3906,7 @@ Struct_type::do_get_init_tree(Gogo* gogo, tree type_tree, bool is_clear) tree value = p->type()->get_init_tree(gogo, is_clear); if (value == error_mark_node) return error_mark_node; - gcc_assert(field != NULL_TREE); + go_assert(field != NULL_TREE); if (value != NULL) { constructor_elt* elt = VEC_quick_push(constructor_elt, init, NULL); @@ -3917,11 +3917,11 @@ Struct_type::do_get_init_tree(Gogo* gogo, tree type_tree, bool is_clear) is_constant = false; } } - gcc_assert(field == NULL_TREE); + go_assert(field == NULL_TREE); if (!any_fields_set) { - gcc_assert(is_clear); + go_assert(is_clear); VEC_free(constructor_elt, gc, init); return NULL; } @@ -3985,16 +3985,16 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_type* name) const Methods* methods = this->methods(); // A named struct should not have methods--the methods should attach // to the named type. - gcc_assert(methods == NULL || name == NULL); + go_assert(methods == NULL || name == NULL); Struct_field_list::const_iterator ps = fields->begin(); - gcc_assert(ps->field_name() == "commonType"); + go_assert(ps->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_STRUCT, name, methods, true)); ++ps; - gcc_assert(ps->field_name() == "fields"); + go_assert(ps->field_name() == "fields"); Expression_list* elements = new Expression_list(); elements->reserve(this->fields_->size()); @@ -4009,7 +4009,7 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_type* name) fvals->reserve(5); Struct_field_list::const_iterator q = f->begin(); - gcc_assert(q->field_name() == "name"); + go_assert(q->field_name() == "name"); if (pf->is_anonymous()) fvals->push_back(Expression::make_nil(bloc)); else @@ -4020,7 +4020,7 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_type* name) } ++q; - gcc_assert(q->field_name() == "pkgPath"); + go_assert(q->field_name() == "pkgPath"); if (!Gogo::is_hidden_name(pf->field_name())) fvals->push_back(Expression::make_nil(bloc)); else @@ -4031,11 +4031,11 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_type* name) } ++q; - gcc_assert(q->field_name() == "typ"); + go_assert(q->field_name() == "typ"); fvals->push_back(Expression::make_type_descriptor(pf->type(), bloc)); ++q; - gcc_assert(q->field_name() == "tag"); + go_assert(q->field_name() == "tag"); if (!pf->has_tag()) fvals->push_back(Expression::make_nil(bloc)); else @@ -4045,7 +4045,7 @@ Struct_type::do_type_descriptor(Gogo* gogo, Named_type* name) } ++q; - gcc_assert(q->field_name() == "offset"); + go_assert(q->field_name() == "offset"); fvals->push_back(Expression::make_struct_field_offset(this, &*pf)); Expression* v = Expression::make_struct_composite_literal(element_type, @@ -4170,7 +4170,7 @@ Struct_type::do_export(Export* exp) const { exp->write_c_string("struct { "); const Struct_field_list* fields = this->fields_; - gcc_assert(fields != NULL); + go_assert(fields != NULL); for (Struct_field_list::const_iterator p = fields->begin(); p != fields->end(); ++p) @@ -4226,7 +4226,7 @@ Struct_type::do_import(Import* imp) imp->advance(1); Expression* expr = Expression::import_expression(imp); String_expression* sexpr = expr->string_expression(); - gcc_assert(sexpr != NULL); + go_assert(sexpr != NULL); sf.set_tag(sexpr->val()); delete sexpr; } @@ -4413,7 +4413,7 @@ bool Array_type::do_check_make_expression(Expression_list* args, source_location location) { - gcc_assert(this->length_ == NULL); + go_assert(this->length_ == NULL); if (args == NULL || args->empty()) { error_at(location, "length required when allocating a slice"); @@ -4448,7 +4448,7 @@ Array_type::do_check_make_expression(Expression_list* args, tree Array_type::get_length_tree(Gogo* gogo) { - gcc_assert(this->length_ != NULL); + go_assert(this->length_ != NULL); if (this->length_tree_ == NULL_TREE) { mpz_t val; @@ -4509,7 +4509,7 @@ Array_type::do_get_tree(Gogo* gogo) tree Array_type::fill_in_array_tree(Gogo* gogo, tree array_type) { - gcc_assert(this->length_ != NULL); + go_assert(this->length_ != NULL); tree element_type_tree = this->element_type_->get_tree(gogo); tree length_tree = this->get_length_tree(gogo); @@ -4517,7 +4517,7 @@ Array_type::fill_in_array_tree(Gogo* gogo, tree array_type) || length_tree == error_mark_node) return error_mark_node; - gcc_assert(TYPE_SIZE(element_type_tree) != NULL_TREE); + go_assert(TYPE_SIZE(element_type_tree) != NULL_TREE); length_tree = fold_convert(sizetype, length_tree); @@ -4550,14 +4550,14 @@ Array_type::fill_in_array_tree(Gogo* gogo, tree array_type) tree Array_type::fill_in_slice_tree(Gogo* gogo, tree struct_type) { - gcc_assert(this->length_ == NULL); + go_assert(this->length_ == NULL); tree element_type_tree = this->element_type_->get_tree(gogo); if (element_type_tree == error_mark_node) return error_mark_node; tree field = TYPE_FIELDS(struct_type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); - gcc_assert(POINTER_TYPE_P(TREE_TYPE(field)) + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); + go_assert(POINTER_TYPE_P(TREE_TYPE(field)) && TREE_TYPE(TREE_TYPE(field)) == void_type_node); TREE_TYPE(field) = build_pointer_type(element_type_tree); @@ -4576,7 +4576,7 @@ Array_type::do_get_init_tree(Gogo* gogo, tree type_tree, bool is_clear) if (is_clear) return NULL; - gcc_assert(TREE_CODE(type_tree) == RECORD_TYPE); + go_assert(TREE_CODE(type_tree) == RECORD_TYPE); VEC(constructor_elt,gc)* init = VEC_alloc(constructor_elt, gc, 3); @@ -4626,7 +4626,7 @@ Array_type::do_make_expression_tree(Translate_context* context, Expression_list* args, source_location location) { - gcc_assert(this->length_ == NULL); + go_assert(this->length_ == NULL); Gogo* gogo = context->gogo(); tree type_tree = this->get_tree(gogo); @@ -4634,11 +4634,11 @@ Array_type::do_make_expression_tree(Translate_context* context, return error_mark_node; tree values_field = TYPE_FIELDS(type_tree); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(values_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(values_field)), "__values") == 0); tree count_field = DECL_CHAIN(values_field); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(count_field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(count_field)), "__count") == 0); tree element_type_tree = this->element_type_->get_tree(gogo); @@ -4652,7 +4652,7 @@ Array_type::do_make_expression_tree(Translate_context* context, // The first argument is the number of elements, the optional second // argument is the capacity. - gcc_assert(args != NULL && args->size() >= 1 && args->size() <= 2); + go_assert(args != NULL && args->size() >= 1 && args->size() <= 2); tree length_tree = args->front()->get_tree(context); if (length_tree == error_mark_node) @@ -4795,7 +4795,7 @@ Array_type::value_pointer_tree(Gogo*, tree array) const { // Open array. tree field = TYPE_FIELDS(TREE_TYPE(array)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__values") == 0); ret = fold_build3(COMPONENT_REF, TREE_TYPE(field), array, field, NULL_TREE); @@ -4823,10 +4823,10 @@ Array_type::length_tree(Gogo* gogo, tree array) // This is an open array. We need to read the length field. tree type = TREE_TYPE(array); - gcc_assert(TREE_CODE(type) == RECORD_TYPE); + go_assert(TREE_CODE(type) == RECORD_TYPE); tree field = DECL_CHAIN(TYPE_FIELDS(type)); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__count") == 0); tree ret = build3(COMPONENT_REF, TREE_TYPE(field), array, field, NULL_TREE); if (TREE_CONSTANT(array)) @@ -4846,10 +4846,10 @@ Array_type::capacity_tree(Gogo* gogo, tree array) // This is an open array. We need to read the capacity field. tree type = TREE_TYPE(array); - gcc_assert(TREE_CODE(type) == RECORD_TYPE); + go_assert(TREE_CODE(type) == RECORD_TYPE); tree field = DECL_CHAIN(DECL_CHAIN(TYPE_FIELDS(type))); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__capacity") == 0); return build3(COMPONENT_REF, TREE_TYPE(field), array, field, NULL_TREE); } @@ -4955,21 +4955,21 @@ Array_type::array_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(3); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_ARRAY, name, NULL, true)); ++p; - gcc_assert(p->field_name() == "elem"); + go_assert(p->field_name() == "elem"); vals->push_back(Expression::make_type_descriptor(this->element_type_, bloc)); ++p; - gcc_assert(p->field_name() == "len"); + go_assert(p->field_name() == "len"); vals->push_back(Expression::make_cast(p->type(), this->length_, bloc)); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(atdt, vals, bloc); } @@ -4989,17 +4989,17 @@ Array_type::slice_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(2); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_SLICE, name, NULL, true)); ++p; - gcc_assert(p->field_name() == "elem"); + go_assert(p->field_name() == "elem"); vals->push_back(Expression::make_type_descriptor(this->element_type_, bloc)); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(stdt, vals, bloc); } @@ -5303,21 +5303,21 @@ Map_type::do_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(3); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_MAP, name, NULL, true)); ++p; - gcc_assert(p->field_name() == "key"); + go_assert(p->field_name() == "key"); vals->push_back(Expression::make_type_descriptor(this->key_type_, bloc)); ++p; - gcc_assert(p->field_name() == "elem"); + go_assert(p->field_name() == "elem"); vals->push_back(Expression::make_type_descriptor(this->val_type_, bloc)); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(mtdt, vals, bloc); } @@ -5557,17 +5557,17 @@ Channel_type::do_type_descriptor(Gogo* gogo, Named_type* name) vals->reserve(3); Struct_field_list::const_iterator p = fields->begin(); - gcc_assert(p->field_name() == "commonType"); + go_assert(p->field_name() == "commonType"); vals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_CHAN, name, NULL, true)); ++p; - gcc_assert(p->field_name() == "elem"); + go_assert(p->field_name() == "elem"); vals->push_back(Expression::make_type_descriptor(this->element_type_, bloc)); ++p; - gcc_assert(p->field_name() == "dir"); + go_assert(p->field_name() == "dir"); // These bits must match the ones in libgo/runtime/go-type.h. int val = 0; if (this->may_receive_) @@ -5580,7 +5580,7 @@ Channel_type::do_type_descriptor(Gogo* gogo, Named_type* name) mpz_clear(iv); ++p; - gcc_assert(p == fields->end()); + go_assert(p == fields->end()); return Expression::make_struct_composite_literal(ctdt, vals, bloc); } @@ -5830,7 +5830,7 @@ Interface_type::find_method(const std::string& name) const size_t Interface_type::method_index(const std::string& name) const { - gcc_assert(this->methods_ != NULL); + go_assert(this->methods_ != NULL); size_t ret = 0; for (Typed_identifier_list::const_iterator p = this->methods_->begin(); p != this->methods_->end(); @@ -6053,7 +6053,7 @@ Interface_type::implements_interface(const Type* t, std::string* reason) const Function_type *p_fn_type = p->type()->function_type(); Function_type* m_fn_type = m->type()->function_type(); - gcc_assert(p_fn_type != NULL && m_fn_type != NULL); + go_assert(p_fn_type != NULL && m_fn_type != NULL); std::string subreason; if (!p_fn_type->is_identical(m_fn_type, true, true, &subreason)) { @@ -6170,7 +6170,7 @@ Interface_type::non_empty_type_tree(source_location location) tree Interface_type::fill_in_tree(Gogo* gogo, tree type) { - gcc_assert(this->methods_ != NULL); + go_assert(this->methods_ != NULL); // Build the type of the table of methods. @@ -6200,7 +6200,7 @@ Interface_type::fill_in_tree(Gogo* gogo, tree type) *pp = field; pp = &DECL_CHAIN(field); // Sanity check: the names should be sorted. - gcc_assert(p->name() > last_name); + go_assert(p->name() > last_name); last_name = p->name(); } layout_type(method_table); @@ -6208,7 +6208,7 @@ Interface_type::fill_in_tree(Gogo* gogo, tree type) // Update the type of the __methods field from a generic pointer to // a pointer to the method table. field = TYPE_FIELDS(type); - gcc_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0); + go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)), "__methods") == 0); TREE_TYPE(field) = build_pointer_type(method_table); @@ -6287,13 +6287,13 @@ Interface_type::do_type_descriptor(Gogo* gogo, Named_type* name) ivals->reserve(2); Struct_field_list::const_iterator pif = ifields->begin(); - gcc_assert(pif->field_name() == "commonType"); + go_assert(pif->field_name() == "commonType"); ivals->push_back(this->type_descriptor_constructor(gogo, RUNTIME_TYPE_KIND_INTERFACE, name, NULL, true)); ++pif; - gcc_assert(pif->field_name() == "methods"); + go_assert(pif->field_name() == "methods"); Expression_list* methods = new Expression_list(); if (this->methods_ != NULL && !this->methods_->empty()) @@ -6311,13 +6311,13 @@ Interface_type::do_type_descriptor(Gogo* gogo, Named_type* name) mvals->reserve(3); Struct_field_list::const_iterator pmf = mfields->begin(); - gcc_assert(pmf->field_name() == "name"); + go_assert(pmf->field_name() == "name"); std::string s = Gogo::unpack_hidden_name(pm->name()); Expression* e = Expression::make_string(s, bloc); mvals->push_back(Expression::make_unary(OPERATOR_AND, e, bloc)); ++pmf; - gcc_assert(pmf->field_name() == "pkgPath"); + go_assert(pmf->field_name() == "pkgPath"); if (!Gogo::is_hidden_name(pm->name())) mvals->push_back(Expression::make_nil(bloc)); else @@ -6328,11 +6328,11 @@ Interface_type::do_type_descriptor(Gogo* gogo, Named_type* name) } ++pmf; - gcc_assert(pmf->field_name() == "typ"); + go_assert(pmf->field_name() == "typ"); mvals->push_back(Expression::make_type_descriptor(pm->type(), bloc)); ++pmf; - gcc_assert(pmf == mfields->end()); + go_assert(pmf == mfields->end()); e = Expression::make_struct_composite_literal(elemtype, mvals, bloc); @@ -6344,7 +6344,7 @@ Interface_type::do_type_descriptor(Gogo* gogo, Named_type* name) methods, bloc)); ++pif; - gcc_assert(pif == ifields->end()); + go_assert(pif == ifields->end()); return Expression::make_struct_composite_literal(itdt, ivals, bloc); } @@ -6366,7 +6366,7 @@ Interface_type::do_reflection(Gogo* gogo, std::string* ret) const ret->push_back(' '); ret->append(Gogo::unpack_hidden_name(p->name())); std::string sub = p->type()->reflection(gogo); - gcc_assert(sub.compare(0, 4, "func") == 0); + go_assert(sub.compare(0, 4, "func") == 0); sub = sub.substr(4); ret->append(sub); } @@ -6514,7 +6514,7 @@ Interface_type::do_import(Import* imp) ptype, imp->location())); if (imp->peek_char() != ',') break; - gcc_assert(!is_varargs); + go_assert(!is_varargs); imp->require_c_string(", "); } } @@ -6647,7 +6647,7 @@ Named_method::do_bind_method(Expression* expr, source_location location) const if (this->depth() > 0 && !this->needs_stub_method()) { Function_type* ftype = this->do_type(); - gcc_assert(ftype->is_method()); + go_assert(ftype->is_method()); Type* frtype = ftype->receiver()->type(); bme->set_first_argument_type(frtype); } @@ -6880,7 +6880,7 @@ tree Named_type::interface_method_table(Gogo* gogo, const Interface_type* interface, bool is_pointer) { - gcc_assert(!interface->is_empty()); + go_assert(!interface->is_empty()); Interface_method_tables** pimt = (is_pointer ? &this->interface_method_tables_ @@ -6895,7 +6895,7 @@ Named_type::interface_method_table(Gogo* gogo, const Interface_type* interface, if (ins.second) { // This is a new entry in the hash table. - gcc_assert(ins.first->second == NULL_TREE); + go_assert(ins.first->second == NULL_TREE); ins.first->second = gogo->interface_method_table_for_type(interface, this, is_pointer); @@ -6904,7 +6904,7 @@ Named_type::interface_method_table(Gogo* gogo, const Interface_type* interface, tree decl = ins.first->second; if (decl == error_mark_node) return error_mark_node; - gcc_assert(decl != NULL_TREE && TREE_CODE(decl) == VAR_DECL); + go_assert(decl != NULL_TREE && TREE_CODE(decl) == VAR_DECL); return build_fold_addr_expr(decl); } @@ -7198,7 +7198,7 @@ Named_type::convert(Gogo* gogo) if (t == error_mark_node) this->is_error_ = true; else - gcc_assert(TYPE_SIZE(t) != NULL_TREE); + go_assert(TYPE_SIZE(t) != NULL_TREE); this->is_converted_ = true; } @@ -7330,7 +7330,7 @@ Named_type::do_get_tree(Gogo* gogo) // converting types. this->create_placeholder(gogo); t = this->named_tree_; - gcc_assert(t != NULL_TREE); + go_assert(t != NULL_TREE); return t; } @@ -7338,11 +7338,11 @@ Named_type::do_get_tree(Gogo* gogo) // type has already been converted. if (!this->is_converted_) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return error_mark_node; } - gcc_assert(t != NULL_TREE && TYPE_SIZE(t) != NULL_TREE); + go_assert(t != NULL_TREE && TYPE_SIZE(t) != NULL_TREE); // Complete the tree. Type* base = this->type_->base(); @@ -7380,8 +7380,8 @@ Named_type::do_get_tree(Gogo* gogo) return error_mark_node; if (this->is_circular_) t1 = ptr_type_node; - gcc_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE); - gcc_assert(TREE_CODE(t1) == POINTER_TYPE); + go_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE); + go_assert(TREE_CODE(t1) == POINTER_TYPE); TREE_TYPE(t) = TREE_TYPE(t1); return t; @@ -7400,8 +7400,8 @@ Named_type::do_get_tree(Gogo* gogo) return error_mark_node; if (this->is_circular_) t1 = ptr_type_node; - gcc_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE); - gcc_assert(TREE_CODE(t1) == POINTER_TYPE); + go_assert(t != NULL_TREE && TREE_CODE(t) == POINTER_TYPE); + go_assert(TREE_CODE(t1) == POINTER_TYPE); TREE_TYPE(t) = TREE_TYPE(t1); return t; @@ -7474,7 +7474,7 @@ Named_type::do_mangled_name(Gogo* gogo, std::string* ret) const Named_object* no = this->named_object_; std::string name; if (this->location() == BUILTINS_LOCATION) - gcc_assert(this->in_function_ == NULL); + go_assert(this->in_function_ == NULL); else { const std::string& unique_prefix(no->package() == NULL @@ -7520,7 +7520,7 @@ Named_type::import_named_type(Import* imp, Named_type** ptype) imp->require_c_string("type "); Type *type = imp->read_type(); *ptype = type->named_type(); - gcc_assert(*ptype != NULL); + go_assert(*ptype != NULL); imp->require_c_string(";\n"); } @@ -7755,7 +7755,7 @@ Type::add_interface_methods_for_type(const Type* type, // when we look at the methods for IT. continue; } - gcc_assert(!fntype->is_method()); + go_assert(!fntype->is_method()); fntype = fntype->copy_with_receiver(const_cast(type)); Method* m = new Interface_method(pm->name(), pm->location(), fntype, field_indexes, depth); @@ -7882,7 +7882,7 @@ Type::build_one_stub_method(Gogo* gogo, Method* method, source_location location) { Named_object* receiver_object = gogo->lookup(receiver_name, NULL); - gcc_assert(receiver_object != NULL); + go_assert(receiver_object != NULL); Expression* expr = Expression::make_var_reference(receiver_object, location); expr = Type::apply_field_indexes(expr, method->field_indexes(), location); @@ -7900,7 +7900,7 @@ Type::build_one_stub_method(Gogo* gogo, Method* method, ++p) { Named_object* param = gogo->lookup(p->name(), NULL); - gcc_assert(param != NULL); + go_assert(param != NULL); Expression* param_ref = Expression::make_var_reference(param, location); arguments->push_back(param_ref); @@ -7908,7 +7908,7 @@ Type::build_one_stub_method(Gogo* gogo, Method* method, } Expression* func = method->bind_method(expr, location); - gcc_assert(func != NULL); + go_assert(func != NULL); Call_expression* call = Expression::make_call(func, arguments, is_varargs, location); size_t count = call->result_count(); @@ -7941,13 +7941,13 @@ Type::apply_field_indexes(Expression* expr, return expr; expr = Type::apply_field_indexes(expr, field_indexes->next, location); Struct_type* stype = expr->type()->deref()->struct_type(); - gcc_assert(stype != NULL + go_assert(stype != NULL && field_indexes->field_index < stype->field_count()); if (expr->type()->struct_type() == NULL) { - gcc_assert(expr->type()->points_to() != NULL); + go_assert(expr->type()->points_to() != NULL); expr = Expression::make_unary(OPERATOR_MULT, expr, location); - gcc_assert(expr->type()->struct_type() == stype); + go_assert(expr->type()->struct_type() == stype); } return Expression::make_field_reference(expr, field_indexes->field_index, location); @@ -8040,13 +8040,13 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr, Expression* ret; if (!is_method) { - gcc_assert(st != NULL); + go_assert(st != NULL); if (type->struct_type() == NULL) { - gcc_assert(type->points_to() != NULL); + go_assert(type->points_to() != NULL); expr = Expression::make_unary(OPERATOR_MULT, expr, location); - gcc_assert(expr->type()->struct_type() == st); + go_assert(expr->type()->struct_type() == st); } ret = st->field_reference(expr, name, location); } @@ -8062,12 +8062,12 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr, m = st->method_function(name, NULL); else gcc_unreachable(); - gcc_assert(m != NULL); + go_assert(m != NULL); if (!m->is_value_method() && expr->type()->points_to() == NULL) expr = Expression::make_unary(OPERATOR_AND, expr, location); ret = m->bind_method(expr, location); } - gcc_assert(ret != NULL); + go_assert(ret != NULL); return ret; } else @@ -8222,7 +8222,7 @@ Type::find_field_or_method(const Type* type, Named_type* fnt = pf->type()->named_type(); if (fnt == NULL) fnt = pf->type()->deref()->named_type(); - gcc_assert(fnt != NULL); + go_assert(fnt != NULL); int sublevel = level == NULL ? 1 : *level + 1; bool sub_is_method; @@ -8271,7 +8271,7 @@ Type::find_field_or_method(const Type* type, else if (found_ambig1.empty()) { // We found an ambiguity. - gcc_assert(found_parent != NULL); + go_assert(found_parent != NULL); found_ambig1 = found_parent->field_name(); found_ambig2 = pf->field_name(); } @@ -8295,7 +8295,7 @@ Type::find_field_or_method(const Type* type, return false; else if (!found_ambig1.empty()) { - gcc_assert(!found_ambig1.empty()); + go_assert(!found_ambig1.empty()); ambig1->assign(found_ambig1); ambig2->assign(found_ambig2); if (level != NULL) @@ -8395,7 +8395,7 @@ Forward_declaration_type::Forward_declaration_type(Named_object* named_object) : Type(TYPE_FORWARD), named_object_(named_object->resolve()), warned_(false) { - gcc_assert(this->named_object_->is_unknown() + go_assert(this->named_object_->is_unknown() || this->named_object_->is_type_declaration()); } @@ -8615,7 +8615,7 @@ void Forward_declaration_type::do_export(Export*) const { // If there is a base type, that should be exported instead of this. - gcc_assert(!this->is_defined()); + go_assert(!this->is_defined()); // We don't output anything. } diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index 3255d37ff9e..80593793802 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -160,7 +160,7 @@ class Method Named_object* stub_object() const { - gcc_assert(this->stub_ != NULL); + go_assert(this->stub_ != NULL); return this->stub_; } @@ -168,7 +168,7 @@ class Method void set_stub_object(Named_object* no) { - gcc_assert(this->stub_ == NULL); + go_assert(this->stub_ == NULL); this->stub_ = no; } @@ -1167,7 +1167,7 @@ class Typed_identifier void set_type(Type* type) { - gcc_assert(this->type_ == NULL || type->is_error_type()); + go_assert(this->type_ == NULL || type->is_error_type()); this->type_ = type; } @@ -1213,7 +1213,7 @@ class Typed_identifier_list void set_type(size_t i, Type* type) { - gcc_assert(i < this->entries_.size()); + go_assert(i < this->entries_.size()); this->entries_[i].set_type(type); } @@ -1253,7 +1253,7 @@ class Typed_identifier_list void resize(size_t c) { - gcc_assert(c <= this->entries_.size()); + go_assert(c <= this->entries_.size()); this->entries_.resize(c, Typed_identifier("", NULL, UNKNOWN_LOCATION)); } @@ -1777,7 +1777,7 @@ class Struct_field const std::string& tag() const { - gcc_assert(this->tag_ != NULL); + go_assert(this->tag_ != NULL); return *this->tag_; } @@ -2228,7 +2228,7 @@ class Channel_type : public Type : Type(TYPE_CHANNEL), may_send_(may_send), may_receive_(may_receive), element_type_(element_type) - { gcc_assert(may_send || may_receive); } + { go_assert(may_send || may_receive); } // Whether this channel can send data. bool @@ -2312,7 +2312,7 @@ class Interface_type : public Type Interface_type(Typed_identifier_list* methods, source_location location) : Type(TYPE_INTERFACE), methods_(methods), location_(location) - { gcc_assert(methods == NULL || !methods->empty()); } + { go_assert(methods == NULL || !methods->empty()); } // The location where the interface type was defined. source_location diff --git a/gcc/go/gofrontend/unsafe.cc b/gcc/go/gofrontend/unsafe.cc index 9d51b4d9424..80b367cc46d 100644 --- a/gcc/go/gofrontend/unsafe.cc +++ b/gcc/go/gofrontend/unsafe.cc @@ -27,7 +27,7 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported, if (package == NULL) { - gcc_assert(saw_errors()); + go_assert(saw_errors()); return; } @@ -44,9 +44,9 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported, } else { - gcc_assert(no->package() == package); - gcc_assert(no->is_type()); - gcc_assert(no->type_value()->is_unsafe_pointer_type()); + go_assert(no->package() == package); + go_assert(no->is_type()); + go_assert(no->type_value()->is_unsafe_pointer_type()); no->type_value()->set_is_visible(); } Named_type* pointer_type = no->type_value(); -- 2.30.2