This is defined in go-system.h in the backend.
* go-system.h (go_assert, go_unreachable): Define.
From-SVN: r172846
+2011-04-21 Ian Lance Taylor <iant@google.com>
+
+ * go-system.h (go_assert, go_unreachable): Define.
+
2011-04-19 Ian Lance Taylor <iant@google.com>
* go-system.h: Include "intl.h".
} // 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)
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
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;
{
Expression* e = init;
this->value(&e, true, true);
- gcc_assert(e == init);
+ go_assert(e == init);
}
}
{
// 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, "<type %d>", index);
this->write_c_string(buf);
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();
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<Type_refs::iterator, bool> 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.
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;
&& 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);
{
// 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))
{
// 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;
}
}
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)
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)
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);
{
// 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;
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);
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);
// 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();
}
{
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");
}
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;
if (!this->function_->is_function()
|| this->function_->func_value()->enclosing() == NULL)
{
- gcc_assert(this->closure_ == NULL);
+ go_assert(this->closure_ == NULL);
return fnaddr;
}
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
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);
}
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);
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);
}
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(),
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)
{
}
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(),
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
void
set_does_not_escape()
{
- gcc_assert(this->op_ == OPERATOR_AND);
+ go_assert(this->op_ == OPERATOR_AND);
this->escapes_ = false;
}
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();
++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];
// 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))
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
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;
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)
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)
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,
// 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,
{
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,
{
// 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);
}
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);
}
}
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;
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);
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);
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)
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;
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);
}
{
if (this->seen_)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return error_mark_node;
}
this->seen_ = true;
{
if (this->seen_)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return error_mark_node;
}
this->seen_ = true;
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)
// 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)
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)
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);
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();
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();
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)),
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);
{
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());
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)
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
// Lower all the new subexpressions.
Expression* ret = this;
gogo->lower_expression(function, &ret);
- gcc_assert(ret == this);
+ go_assert(ret == this);
return ret;
}
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;
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;
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(),
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)));
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);
}
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;
}
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;
}
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);
{
Map_type* mt = this->map_->type()->deref()->map_type();
if (mt == NULL)
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return mt;
}
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();
}
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.
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;
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)));
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);
}
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);
}
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";
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)
++p)
{
vno = gogo->lookup(p->name(), NULL);
- gcc_assert(vno != NULL);
+ go_assert(vno != NULL);
args->push_back(Expression::make_var_reference(vno, location));
}
}
this->set_is_error();
}
}
- gcc_assert(pv == this->vals_->end());
+ go_assert(pv == this->vals_->end());
}
// Return a tree for constructing a struct.
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();
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())
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)
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);
}
: 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);
}
: 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);
}
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;
}
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);
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);
}
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
Expression* name_expr = *p;
++p;
- gcc_assert(p != this->vals_->end());
+ go_assert(p != this->vals_->end());
Expression* val = *p;
++p;
Expression* index_expr = *p;
++p;
- gcc_assert(p != this->vals_->end());
+ go_assert(p != this->vals_->end());
Expression* val = *p;
++p;
{
(*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);
}
}
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);
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();
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,
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);
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));
void
set_struct_expression(Expression* expr)
{
- gcc_assert(this->expr_ == NULL);
+ go_assert(this->expr_ == NULL);
this->expr_ = expr;
}
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);
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)
{
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.
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;
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);
{
// 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();
{
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())
{
vec[i] = no->get_tree(this, NULL);
if (vec[i] == error_mark_node)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
--i;
--count;
continue;
vec[i] = var_to_tree(var);
if (vec[i] == error_mark_node)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
--i;
--count;
continue;
{
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))
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())
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
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()));
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
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
{
// 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);
{
// 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;
{
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);
}
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),
{
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));
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);
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;
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;
}
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;
}
if (*pp != error_mark_node)
{
- gcc_assert(TREE_CODE(*pp) == PARM_DECL);
+ go_assert(TREE_CODE(*pp) == PARM_DECL);
pp = &DECL_CHAIN(*pp);
}
}
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;
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;
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
append_to_statement_list(ret_stmt, &stmt_list);
}
- gcc_assert(*fini == NULL_TREE);
+ go_assert(*fini == NULL_TREE);
*fini = stmt_list;
}
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;
}
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);
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),
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());
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)));
}
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;
}
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);
{
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);
}
}
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);
{
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
tree constructor = initializer->get_tree(&context);
if (constructor == error_mark_node)
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
DECL_INITIAL(decl) = constructor;
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);
}
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)
{
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();
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)));
const std::string&
Gogo::package_name() const
{
- gcc_assert(this->package_ != NULL);
+ go_assert(this->package_ != NULL);
return this->package_->name();
}
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);
}
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.
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<Packages::iterator, bool> ins =
{
// 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);
{
// 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;
}
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
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,
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();
}
Named_object*
Gogo::current_function() const
{
- gcc_assert(!this->functions_.empty());
+ go_assert(!this->functions_.empty());
return this->functions_.back().function;
}
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);
}
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);
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));
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);
}
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);
}
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);
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);
}
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;
{
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;
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);
}
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;
}
++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));
// 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();
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();
}
// 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);
const std::string&
Gogo::unique_prefix() const
{
- gcc_assert(!this->unique_prefix_.empty());
+ go_assert(!this->unique_prefix_.empty());
return this->unique_prefix_;
}
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;
}
++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);
}
}
}
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();
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.
ptype, imp->location()));
if (imp->peek_char() != ',')
break;
- gcc_assert(!*is_varargs);
+ go_assert(!*is_varargs);
imp->require_c_string(", ");
}
}
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;
}
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);
}
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);
}
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.
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());
&& 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;
}
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())
Type*
Variable::type() const
{
- gcc_assert(this->type_ != NULL);
+ go_assert(this->type_ != NULL);
return this->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_;
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();
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(" ");
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);
}
}
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;
}
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
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();
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;
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());
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<Named_object*>::iterator pn = this->named_objects_.begin();
pn != this->named_objects_.end();
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<Contour::iterator, bool> ins =
contour->insert(std::make_pair(name, named_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())
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:
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
{
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.
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();
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);
}
void
set_enclosing(Function* enclosing)
{
- gcc_assert(this->enclosing_ == NULL);
+ go_assert(this->enclosing_ == NULL);
this->enclosing_ = enclosing;
}
void
set_closure_var(Named_object* v)
{
- gcc_assert(this->closure_var_ == NULL);
+ go_assert(this->closure_var_ == NULL);
this->closure_var_ = v;
}
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;
}
tree
get_decl() const
{
- gcc_assert(this->fndecl_ != NULL);
+ go_assert(this->fndecl_ != NULL);
return this->fndecl_;
}
void
set_is_receiver()
{
- gcc_assert(this->is_parameter_);
+ go_assert(this->is_parameter_);
this->is_receiver_ = true;
}
void
set_is_not_receiver()
{
- gcc_assert(this->is_parameter_);
+ go_assert(this->is_parameter_);
this->is_receiver_ = false;
}
void
set_is_varargs_parameter()
{
- gcc_assert(this->is_parameter_);
+ go_assert(this->is_parameter_);
this->is_varargs_parameter_ = true;
}
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;
}
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;
}
void
define(source_location location)
{
- gcc_assert(this->location_ == 0);
+ go_assert(this->location_ == 0);
this->location_ = location;
}
const std::string&
unique_prefix() const
{
- gcc_assert(!this->unique_prefix_.empty());
+ go_assert(!this->unique_prefix_.empty());
return this->unique_prefix_;
}
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
return Type::make_error_type();
}
else
- gcc_assert(no->package() == package);
+ go_assert(no->package() == package);
if (this->types_[index] == NULL)
{
}
else
{
- gcc_assert(no->is_type());
+ go_assert(no->is_type());
this->types_[index] = no->type_value();
}
}
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<int>(code);
- gcc_assert(index > 0
+ go_assert(index > 0
&& static_cast<size_t>(index) < this->builtin_types_.size());
this->builtin_types_[index] = named_object->type_value();
}
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);
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;
}
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);
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);
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);
Keyword
keyword() const
{
- gcc_assert(this->classification_ == TOKEN_KEYWORD);
+ go_assert(this->classification_ == TOKEN_KEYWORD);
return this->u_.keyword;
}
const std::string&
identifier() const
{
- gcc_assert(this->classification_ == TOKEN_IDENTIFIER);
+ go_assert(this->classification_ == TOKEN_IDENTIFIER);
return *this->u_.identifier_value.name;
}
bool
is_identifier_exported() const
{
- gcc_assert(this->classification_ == TOKEN_IDENTIFIER);
+ go_assert(this->classification_ == TOKEN_IDENTIFIER);
return this->u_.identifier_value.is_exported;
}
std::string
string_value() const
{
- gcc_assert(this->classification_ == TOKEN_STRING);
+ go_assert(this->classification_ == TOKEN_STRING);
return *this->u_.string_value;
}
const mpz_t*
integer_value() const
{
- gcc_assert(this->classification_ == TOKEN_INTEGER);
+ go_assert(this->classification_ == TOKEN_INTEGER);
return &this->u_.integer_value;
}
const mpfr_t*
float_value() const
{
- gcc_assert(this->classification_ == TOKEN_FLOAT);
+ go_assert(this->classification_ == TOKEN_FLOAT);
return &this->u_.float_value;
}
const mpfr_t*
imaginary_value() const
{
- gcc_assert(this->classification_ == TOKEN_IMAGINARY);
+ go_assert(this->classification_ == TOKEN_IMAGINARY);
return &this->u_.float_value;
}
Operator
op() const
{
- gcc_assert(this->classification_ == TOKEN_OPERATOR);
+ go_assert(this->classification_ == TOKEN_OPERATOR);
return this->u_.op;
}
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;
}
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;
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 %<[%>");
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))
{
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())
}
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;
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))
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))
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();
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);
}
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
{
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);
}
++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");
}
// "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();
}
}
- 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))
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();
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();
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();
&& 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());
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();
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))
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;
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)
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();
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;
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();
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);
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();
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;
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();
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();
if (is_default)
{
- gcc_assert(types.empty());
+ go_assert(types.empty());
if (*saw_default)
{
error_at(location, "multiple defaults in type switch");
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();
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();
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;
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");
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");
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();
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();
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())
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);
}
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;
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;
}
}
if (t != NULL && t->named_type() != NULL)
{
bool r = t->verify();
- gcc_assert(r);
+ go_assert(r);
t->named_type()->convert(gogo);
}
}
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];
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<size_t>(param_count)
+ go_assert(static_cast<size_t>(param_count)
<= sizeof(pb->parameter_types) / sizeof(pb->parameter_types[0]));
Named_object* no = runtime_declaration(code);
if (!var->is_in_heap())
{
- gcc_assert(binit != NULL);
+ go_assert(binit != NULL);
return context->backend()->init_statement(bvar, binit);
}
// 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));
if (this->type_ == NULL)
{
this->type_ = this->init_->type();
- gcc_assert(!this->type_->is_abstract());
+ go_assert(!this->type_->is_abstract());
}
}
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.
{
if (this->bvariable_ == NULL)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return context->backend()->error_variable();
}
return this->bvariable_;
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()
temps.push_back(temp);
}
- gcc_assert(prhs == this->rhs_->end());
+ go_assert(prhs == this->rhs_->end());
prhs = this->rhs_->begin();
std::vector<Temporary_statement*>::const_iterator ptemp = temps.begin();
b->add_statement(s);
++ptemp;
}
- gcc_assert(ptemp == temps.end());
+ go_assert(ptemp == temps.end());
return Statement::make_block_statement(b, loc);
}
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;
Function_type* fntype = ce->get_function_type();
if (fntype == NULL)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
this->set_is_error();
return false;
}
// 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,
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
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)
// 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.
}
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;
}
call_params->push_back(param);
else
{
- gcc_assert(call_params->empty());
+ go_assert(call_params->empty());
recover_arg = param;
}
}
*parg = Expression::make_nil(this->location());
else
{
- gcc_assert(args->size() == 1);
+ go_assert(args->size() == 1);
*parg = args->front();
}
i, reason.c_str());
}
}
- gcc_assert(lhs->size() == rhs->size());
+ go_assert(lhs->size() == rhs->size());
if (lhs->empty())
;
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);
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
{
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)
{
// 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);
}
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;
&& 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);
}
if (this->is_fallthrough_)
- gcc_assert(next_case_label == NULL);
+ go_assert(next_case_label == NULL);
else
{
source_location gloc = (this->statements_ == NULL
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);
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();
}
{
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;
}
}
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_,
}
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);
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.
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));
}
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();
}
{
// 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();
}
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)
return ldef;
return context->backend()->compound_statement(s, ldef);
}
- gcc_assert(count > 0);
+ go_assert(count > 0);
std::vector<Bstatement*> statements;
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;
}
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);
Block** piter_init,
Block** ppost)
{
- gcc_assert(value_temp == NULL);
+ go_assert(value_temp == NULL);
source_location loc = this->location();
: 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
bool
is_send() const
{
- gcc_assert(!this->is_default_);
+ go_assert(!this->is_default_);
return this->is_send_;
}
void
add_clauses(Select_clauses* clauses)
{
- gcc_assert(this->clauses_ == NULL);
+ go_assert(this->clauses_ == NULL);
this->clauses_ = clauses;
}
void
add_statements(Block* statements)
{
- gcc_assert(this->statements_ == NULL);
+ go_assert(this->statements_ == NULL);
this->statements_ = statements;
}
void
add_statements(Block* statements)
{
- gcc_assert(this->statements_ == NULL);
+ go_assert(this->statements_ == NULL);
this->statements_ = statements;
}
void
add_clauses(Case_clauses* clauses)
{
- gcc_assert(this->clauses_ == NULL);
+ go_assert(this->clauses_ == NULL);
this->clauses_ = clauses;
}
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;
}
Type*
Type::make_non_abstract_type()
{
- gcc_assert(this->is_abstract());
+ go_assert(this->is_abstract());
switch (this->classification())
{
case TYPE_INTEGER:
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))
{
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_)));
}
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);
}
++p)
{
bool r = (*p)->verify();
- gcc_assert(r);
+ go_assert(r);
(*p)->convert(gogo);
}
}
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));
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,
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)),
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
}
++p;
- gcc_assert(p->field_name() == "ptrToThis");
+ go_assert(p->field_name() == "ptrToThis");
if (name == NULL)
vals->push_back(Expression::make_nil(bloc));
else
}
++p;
- gcc_assert(p == fields->end());
+ go_assert(p == fields->end());
mpz_clear(iv);
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)
{
}
++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);
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
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);
}
void
do_reflection(Gogo*, std::string*) const
- { gcc_assert(saw_errors()); }
+ { go_assert(saw_errors()); }
void
do_mangled_name(Gogo*, std::string* ret) const
else
{
Named_object* no = gogo->lookup_global("bool");
- gcc_assert(no != NULL);
+ go_assert(no != NULL);
return Type::type_descriptor(gogo, no->type_value());
}
}
Named_type* named_type = named_object->type_value();
std::pair<Named_integer_types::iterator, bool> ins =
Integer_type::named_integer_types.insert(std::make_pair(sname, named_type));
- gcc_assert(ins.second);
+ go_assert(ins.second);
return named_type;
}
{
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;
}
{
if (this->is_abstract_)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return error_mark_node;
}
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);
}
void
Integer_type::do_reflection(Gogo*, std::string*) const
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
}
// Mangled name.
Named_type* named_type = named_object->type_value();
std::pair<Named_float_types::iterator, bool> ins =
Float_type::named_float_types.insert(std::make_pair(sname, named_type));
- gcc_assert(ins.second);
+ go_assert(ins.second);
return named_type;
}
{
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;
}
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);
}
void
Float_type::do_reflection(Gogo*, std::string*) const
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
}
// Mangled name.
std::pair<Named_complex_types::iterator, bool> ins =
Complex_type::named_complex_types.insert(std::make_pair(sname,
named_type));
- gcc_assert(ins.second);
+ go_assert(ins.second);
return named_type;
}
{
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;
}
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);
}
void
Complex_type::do_reflection(Gogo*, std::string*) const
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
}
// Mangled name.
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);
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);
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);
else
{
Named_object* no = gogo->lookup_global("string");
- gcc_assert(no != NULL);
+ go_assert(no != NULL);
return Type::type_descriptor(gogo, no->type_value());
}
}
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);
}
{
// 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");
ptype, imp->location()));
if (imp->peek_char() != ',')
break;
- gcc_assert(!is_varargs);
+ go_assert(!is_varargs);
imp->require_c_string(", ");
}
}
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_);
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_,
{
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);
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);
bool
do_has_pointer() const
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return false;
}
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.
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;
{
// 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)
while (sub->expr() != NULL)
{
sub = sub->expr()->deref()->field_reference_expression();
- gcc_assert(sub != NULL);
+ go_assert(sub != NULL);
}
sub->set_struct_expression(here);
}
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);
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);
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;
}
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());
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
}
++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
}
++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
}
++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,
{
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)
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;
}
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");
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;
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);
|| 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);
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);
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);
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);
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);
// 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)
{
// 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);
// 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))
// 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);
}
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);
}
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);
}
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);
}
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_)
mpz_clear(iv);
++p;
- gcc_assert(p == fields->end());
+ go_assert(p == fields->end());
return Expression::make_struct_composite_literal(ctdt, vals, bloc);
}
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();
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))
{
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.
*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);
// 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);
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())
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
}
++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);
methods, bloc));
++pif;
- gcc_assert(pif == ifields->end());
+ go_assert(pif == ifields->end());
return Expression::make_struct_composite_literal(itdt, ivals, bloc);
}
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);
}
ptype, imp->location()));
if (imp->peek_char() != ',')
break;
- gcc_assert(!is_varargs);
+ go_assert(!is_varargs);
imp->require_c_string(", ");
}
}
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);
}
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_
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);
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);
}
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;
}
// converting types.
this->create_placeholder(gogo);
t = this->named_tree_;
- gcc_assert(t != NULL_TREE);
+ go_assert(t != NULL_TREE);
return t;
}
// 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();
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;
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;
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
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");
}
// 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*>(type));
Method* m = new Interface_method(pm->name(), pm->location(), fntype,
field_indexes, depth);
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);
++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);
}
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();
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);
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);
}
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
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;
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();
}
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)
: 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());
}
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.
}
Named_object*
stub_object() const
{
- gcc_assert(this->stub_ != NULL);
+ go_assert(this->stub_ != NULL);
return this->stub_;
}
void
set_stub_object(Named_object* no)
{
- gcc_assert(this->stub_ == NULL);
+ go_assert(this->stub_ == NULL);
this->stub_ = no;
}
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;
}
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);
}
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));
}
const std::string&
tag() const
{
- gcc_assert(this->tag_ != NULL);
+ go_assert(this->tag_ != NULL);
return *this->tag_;
}
: 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
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
if (package == NULL)
{
- gcc_assert(saw_errors());
+ go_assert(saw_errors());
return;
}
}
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();