Commit 26409c52 by Ian Lance Taylor Committed by Ian Lance Taylor

Define go_assert to replace gcc_assert

This is defined in go-system.h in the backend.

	* go-system.h (go_assert, go_unreachable): Define.

From-SVN: r172846
parent 3a6448ea
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> 2011-04-19 Ian Lance Taylor <iant@google.com>
* go-system.h: Include "intl.h". * go-system.h: Include "intl.h".
......
...@@ -151,4 +151,10 @@ extern "C" ...@@ -151,4 +151,10 @@ extern "C"
} // End extern "C" } // End extern "C"
#endif #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) #endif // !defined(GO_SYSTEM_H)
...@@ -24,7 +24,7 @@ Issues to be faced in this transition: ...@@ -24,7 +24,7 @@ Issues to be faced in this transition:
features such as %<%> for appropriate quoting. features such as %<%> for appropriate quoting.
+ Localization may be an issue. + 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 This compiler works, but the code is a work in progress. Notably, the
support for garbage collection is ineffective and needs a complete support for garbage collection is ineffective and needs a complete
......
...@@ -49,7 +49,7 @@ get_var(Expression* expr) ...@@ -49,7 +49,7 @@ get_var(Expression* expr)
if (ve == NULL) if (ve == NULL)
return NULL; return NULL;
Named_object* no = ve->named_object(); 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()) if (no->is_variable() && no->var_value()->is_global())
return NULL; return NULL;
return no; return no;
...@@ -103,7 +103,7 @@ Dataflow_traverse_assignment::initialize_variable(Named_object* var) ...@@ -103,7 +103,7 @@ Dataflow_traverse_assignment::initialize_variable(Named_object* var)
{ {
Expression* e = init; Expression* e = init;
this->value(&e, true, true); this->value(&e, true, true);
gcc_assert(e == init); go_assert(e == init);
} }
} }
......
...@@ -266,7 +266,7 @@ Export::write_type(const Type* type) ...@@ -266,7 +266,7 @@ Export::write_type(const Type* type)
{ {
// This type was already in the table. // This type was already in the table.
int index = p->second; int index = p->second;
gcc_assert(index != 0); go_assert(index != 0);
char buf[30]; char buf[30];
snprintf(buf, sizeof buf, "<type %d>", index); snprintf(buf, sizeof buf, "<type %d>", index);
this->write_c_string(buf); this->write_c_string(buf);
...@@ -289,7 +289,7 @@ Export::write_type(const Type* type) ...@@ -289,7 +289,7 @@ Export::write_type(const Type* type)
if (named_type != NULL) if (named_type != NULL)
{ {
// The builtin types should have been predefined. // 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() || (named_type->named_object()->package()->name()
== "unsafe")); == "unsafe"));
named_object = named_type->named_object(); named_object = named_type->named_object();
...@@ -355,16 +355,16 @@ void ...@@ -355,16 +355,16 @@ void
Export::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) Export::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code)
{ {
Named_object* named_object = gogo->lookup_global(name); 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 = std::pair<Type_refs::iterator, bool> ins =
this->type_refs_.insert(std::make_pair(named_object->type_value(), code)); 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 // We also insert the underlying type. We can see the underlying
// type at least for string and bool. // type at least for string and bool.
Type* real_type = named_object->type_value()->real_type(); Type* real_type = named_object->type_value()->real_type();
ins = this->type_refs_.insert(std::make_pair(real_type, code)); ins = this->type_refs_.insert(std::make_pair(real_type, code));
gcc_assert(ins.second); go_assert(ins.second);
} }
// Class Export::Stream. // Class Export::Stream.
...@@ -428,7 +428,7 @@ Stream_to_section::do_write(const char* bytes, size_t length) ...@@ -428,7 +428,7 @@ Stream_to_section::do_write(const char* bytes, size_t length)
section* sec = (section*) this->section_; section* sec = (section*) this->section_;
if (sec == NULL) if (sec == NULL)
{ {
gcc_assert(targetm.have_named_sections); go_assert(targetm.have_named_sections);
sec = get_section(".go_export", SECTION_DEBUG, NULL); sec = get_section(".go_export", SECTION_DEBUG, NULL);
this->section_ = (void*) sec; this->section_ = (void*) sec;
......
...@@ -1641,7 +1641,7 @@ class Field_reference_expression : public Expression ...@@ -1641,7 +1641,7 @@ class Field_reference_expression : public Expression
void void
set_struct_expression(Expression* expr) set_struct_expression(Expression* expr)
{ {
gcc_assert(this->expr_ == NULL); go_assert(this->expr_ == NULL);
this->expr_ = expr; this->expr_ = expr;
} }
......
...@@ -27,7 +27,7 @@ GO_EXTERN_C ...@@ -27,7 +27,7 @@ GO_EXTERN_C
void void
go_create_gogo(int int_type_size, int pointer_size) 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); ::gogo = new Gogo(go_get_backend(), int_type_size, pointer_size);
if (!unique_prefix.empty()) if (!unique_prefix.empty())
::gogo->set_unique_prefix(unique_prefix); ::gogo->set_unique_prefix(unique_prefix);
...@@ -60,7 +60,7 @@ void ...@@ -60,7 +60,7 @@ void
go_parse_input_files(const char** filenames, unsigned int filename_count, go_parse_input_files(const char** filenames, unsigned int filename_count,
bool only_check_syntax, bool require_return_statement) 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) for (unsigned int i = 0; i < filename_count; ++i)
{ {
if (i > 0) if (i > 0)
......
...@@ -156,7 +156,7 @@ class Gogo ...@@ -156,7 +156,7 @@ class Gogo
static std::string static std::string
hidden_name_prefix(const std::string& name) 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); return name.substr(1, name.rfind('.') - 1);
} }
...@@ -819,7 +819,7 @@ class Function ...@@ -819,7 +819,7 @@ class Function
void void
set_enclosing(Function* enclosing) set_enclosing(Function* enclosing)
{ {
gcc_assert(this->enclosing_ == NULL); go_assert(this->enclosing_ == NULL);
this->enclosing_ = enclosing; this->enclosing_ = enclosing;
} }
...@@ -865,7 +865,7 @@ class Function ...@@ -865,7 +865,7 @@ class Function
void void
set_closure_var(Named_object* v) set_closure_var(Named_object* v)
{ {
gcc_assert(this->closure_var_ == NULL); go_assert(this->closure_var_ == NULL);
this->closure_var_ = v; this->closure_var_ = v;
} }
...@@ -874,7 +874,7 @@ class Function ...@@ -874,7 +874,7 @@ class Function
Named_object* Named_object*
enclosing_var(unsigned int index) enclosing_var(unsigned int index)
{ {
gcc_assert(index < this->closure_fields_.size()); go_assert(index < this->closure_fields_.size());
return closure_fields_[index].first; return closure_fields_[index].first;
} }
...@@ -961,7 +961,7 @@ class Function ...@@ -961,7 +961,7 @@ class Function
tree tree
get_decl() const get_decl() const
{ {
gcc_assert(this->fndecl_ != NULL); go_assert(this->fndecl_ != NULL);
return this->fndecl_; return this->fndecl_;
} }
...@@ -1147,7 +1147,7 @@ class Variable ...@@ -1147,7 +1147,7 @@ class Variable
void void
set_is_receiver() set_is_receiver()
{ {
gcc_assert(this->is_parameter_); go_assert(this->is_parameter_);
this->is_receiver_ = true; this->is_receiver_ = true;
} }
...@@ -1156,7 +1156,7 @@ class Variable ...@@ -1156,7 +1156,7 @@ class Variable
void void
set_is_not_receiver() set_is_not_receiver()
{ {
gcc_assert(this->is_parameter_); go_assert(this->is_parameter_);
this->is_receiver_ = false; this->is_receiver_ = false;
} }
...@@ -1184,7 +1184,7 @@ class Variable ...@@ -1184,7 +1184,7 @@ class Variable
void void
set_is_varargs_parameter() set_is_varargs_parameter()
{ {
gcc_assert(this->is_parameter_); go_assert(this->is_parameter_);
this->is_varargs_parameter_ = true; this->is_varargs_parameter_ = true;
} }
...@@ -1250,7 +1250,7 @@ class Variable ...@@ -1250,7 +1250,7 @@ class Variable
void void
clear_type_from_chan_element() 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; this->type_from_chan_element_ = false;
} }
...@@ -1722,126 +1722,126 @@ class Named_object ...@@ -1722,126 +1722,126 @@ class Named_object
Unknown_name* Unknown_name*
unknown_value() unknown_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); go_assert(this->classification_ == NAMED_OBJECT_UNKNOWN);
return this->u_.unknown_value; return this->u_.unknown_value;
} }
const Unknown_name* const Unknown_name*
unknown_value() const unknown_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_UNKNOWN); go_assert(this->classification_ == NAMED_OBJECT_UNKNOWN);
return this->u_.unknown_value; return this->u_.unknown_value;
} }
Named_constant* Named_constant*
const_value() const_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_CONST); go_assert(this->classification_ == NAMED_OBJECT_CONST);
return this->u_.const_value; return this->u_.const_value;
} }
const Named_constant* const Named_constant*
const_value() const const_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_CONST); go_assert(this->classification_ == NAMED_OBJECT_CONST);
return this->u_.const_value; return this->u_.const_value;
} }
Named_type* Named_type*
type_value() type_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_TYPE); go_assert(this->classification_ == NAMED_OBJECT_TYPE);
return this->u_.type_value; return this->u_.type_value;
} }
const Named_type* const Named_type*
type_value() const type_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_TYPE); go_assert(this->classification_ == NAMED_OBJECT_TYPE);
return this->u_.type_value; return this->u_.type_value;
} }
Type_declaration* Type_declaration*
type_declaration_value() type_declaration_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION); go_assert(this->classification_ == NAMED_OBJECT_TYPE_DECLARATION);
return this->u_.type_declaration; return this->u_.type_declaration;
} }
const Type_declaration* const Type_declaration*
type_declaration_value() const 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; return this->u_.type_declaration;
} }
Variable* Variable*
var_value() var_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_VAR); go_assert(this->classification_ == NAMED_OBJECT_VAR);
return this->u_.var_value; return this->u_.var_value;
} }
const Variable* const Variable*
var_value() const var_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_VAR); go_assert(this->classification_ == NAMED_OBJECT_VAR);
return this->u_.var_value; return this->u_.var_value;
} }
Result_variable* Result_variable*
result_var_value() 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; return this->u_.result_var_value;
} }
const Result_variable* const Result_variable*
result_var_value() const 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; return this->u_.result_var_value;
} }
Function* Function*
func_value() func_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_FUNC); go_assert(this->classification_ == NAMED_OBJECT_FUNC);
return this->u_.func_value; return this->u_.func_value;
} }
const Function* const Function*
func_value() const func_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_FUNC); go_assert(this->classification_ == NAMED_OBJECT_FUNC);
return this->u_.func_value; return this->u_.func_value;
} }
Function_declaration* Function_declaration*
func_declaration_value() 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; return this->u_.func_declaration_value;
} }
const Function_declaration* const Function_declaration*
func_declaration_value() const 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; return this->u_.func_declaration_value;
} }
Package* Package*
package_value() package_value()
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_PACKAGE); go_assert(this->classification_ == NAMED_OBJECT_PACKAGE);
return this->u_.package_value; return this->u_.package_value;
} }
const Package* const Package*
package_value() const package_value() const
{ {
gcc_assert(this->classification_ == NAMED_OBJECT_PACKAGE); go_assert(this->classification_ == NAMED_OBJECT_PACKAGE);
return this->u_.package_value; return this->u_.package_value;
} }
...@@ -2174,7 +2174,7 @@ class Label ...@@ -2174,7 +2174,7 @@ class Label
void void
define(source_location location) define(source_location location)
{ {
gcc_assert(this->location_ == 0); go_assert(this->location_ == 0);
this->location_ = location; this->location_ = location;
} }
...@@ -2263,7 +2263,7 @@ class Package ...@@ -2263,7 +2263,7 @@ class Package
const std::string& const std::string&
unique_prefix() const unique_prefix() const
{ {
gcc_assert(!this->unique_prefix_.empty()); go_assert(!this->unique_prefix_.empty());
return this->unique_prefix_; return this->unique_prefix_;
} }
......
...@@ -456,7 +456,7 @@ Import::import_func(Package* package) ...@@ -456,7 +456,7 @@ Import::import_func(Package* package)
if (rtype->is_error_type()) if (rtype->is_error_type())
return NULL; return NULL;
Named_type* named_rtype = rtype->named_type(); 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); no = named_rtype->add_method_declaration(name, package, fntype, loc);
} }
else else
...@@ -617,7 +617,7 @@ Import::read_type() ...@@ -617,7 +617,7 @@ Import::read_type()
return Type::make_error_type(); return Type::make_error_type();
} }
else else
gcc_assert(no->package() == package); go_assert(no->package() == package);
if (this->types_[index] == NULL) if (this->types_[index] == NULL)
{ {
...@@ -628,7 +628,7 @@ Import::read_type() ...@@ -628,7 +628,7 @@ Import::read_type()
} }
else else
{ {
gcc_assert(no->is_type()); go_assert(no->is_type());
this->types_[index] = no->type_value(); this->types_[index] = no->type_value();
} }
} }
...@@ -714,9 +714,9 @@ void ...@@ -714,9 +714,9 @@ void
Import::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) Import::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code)
{ {
Named_object* named_object = gogo->lookup_global(name); 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); int index = - static_cast<int>(code);
gcc_assert(index > 0 go_assert(index > 0
&& static_cast<size_t>(index) < this->builtin_types_.size()); && static_cast<size_t>(index) < this->builtin_types_.size());
this->builtin_types_[index] = named_object->type_value(); this->builtin_types_[index] = named_object->type_value();
} }
...@@ -842,7 +842,7 @@ Stream_from_file::do_peek(size_t length, const char** bytes) ...@@ -842,7 +842,7 @@ Stream_from_file::do_peek(size_t length, const char** bytes)
return true; return true;
} }
// Don't bother to handle the general case, since we don't need it. // 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]; char buf[64];
ssize_t got = read(this->fd_, buf, length); ssize_t got = read(this->fd_, buf, length);
......
...@@ -132,9 +132,9 @@ Keywords::keyword_to_code(const char* keyword, size_t len) const ...@@ -132,9 +132,9 @@ Keywords::keyword_to_code(const char* keyword, size_t len) const
const char* const char*
Keywords::keyword_to_string(Keyword code) const 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]; const Mapping* map = &this->mapping_[code];
gcc_assert(map->keycode == code); go_assert(map->keycode == code);
return map->keystring; return map->keystring;
} }
...@@ -1005,7 +1005,7 @@ Lex::gather_number() ...@@ -1005,7 +1005,7 @@ Lex::gather_number()
std::string s(pnum, p - pnum); std::string s(pnum, p - pnum);
mpz_t val; mpz_t val;
int r = mpz_init_set_str(val, s.c_str(), base); int r = mpz_init_set_str(val, s.c_str(), base);
gcc_assert(r == 0); go_assert(r == 0);
if (neg) if (neg)
mpz_neg(val, val); mpz_neg(val, val);
...@@ -1029,7 +1029,7 @@ Lex::gather_number() ...@@ -1029,7 +1029,7 @@ Lex::gather_number()
std::string s(pnum, p - pnum); std::string s(pnum, p - pnum);
mpz_t val; mpz_t val;
int r = mpz_init_set_str(val, s.c_str(), 10); int r = mpz_init_set_str(val, s.c_str(), 10);
gcc_assert(r == 0); go_assert(r == 0);
if (neg) if (neg)
mpz_neg(val, val); mpz_neg(val, val);
...@@ -1076,7 +1076,7 @@ Lex::gather_number() ...@@ -1076,7 +1076,7 @@ Lex::gather_number()
std::string s(pnum, p - pnum); std::string s(pnum, p - pnum);
mpfr_t val; mpfr_t val;
int r = mpfr_init_set_str(val, s.c_str(), 10, GMP_RNDN); int r = mpfr_init_set_str(val, s.c_str(), 10, GMP_RNDN);
gcc_assert(r == 0); go_assert(r == 0);
if (neg) if (neg)
mpfr_neg(val, val, GMP_RNDN); mpfr_neg(val, val, GMP_RNDN);
......
...@@ -183,7 +183,7 @@ class Token ...@@ -183,7 +183,7 @@ class Token
Keyword Keyword
keyword() const keyword() const
{ {
gcc_assert(this->classification_ == TOKEN_KEYWORD); go_assert(this->classification_ == TOKEN_KEYWORD);
return this->u_.keyword; return this->u_.keyword;
} }
...@@ -196,7 +196,7 @@ class Token ...@@ -196,7 +196,7 @@ class Token
const std::string& const std::string&
identifier() const identifier() const
{ {
gcc_assert(this->classification_ == TOKEN_IDENTIFIER); go_assert(this->classification_ == TOKEN_IDENTIFIER);
return *this->u_.identifier_value.name; return *this->u_.identifier_value.name;
} }
...@@ -204,7 +204,7 @@ class Token ...@@ -204,7 +204,7 @@ class Token
bool bool
is_identifier_exported() const is_identifier_exported() const
{ {
gcc_assert(this->classification_ == TOKEN_IDENTIFIER); go_assert(this->classification_ == TOKEN_IDENTIFIER);
return this->u_.identifier_value.is_exported; return this->u_.identifier_value.is_exported;
} }
...@@ -220,7 +220,7 @@ class Token ...@@ -220,7 +220,7 @@ class Token
std::string std::string
string_value() const string_value() const
{ {
gcc_assert(this->classification_ == TOKEN_STRING); go_assert(this->classification_ == TOKEN_STRING);
return *this->u_.string_value; return *this->u_.string_value;
} }
...@@ -228,7 +228,7 @@ class Token ...@@ -228,7 +228,7 @@ class Token
const mpz_t* const mpz_t*
integer_value() const integer_value() const
{ {
gcc_assert(this->classification_ == TOKEN_INTEGER); go_assert(this->classification_ == TOKEN_INTEGER);
return &this->u_.integer_value; return &this->u_.integer_value;
} }
...@@ -236,7 +236,7 @@ class Token ...@@ -236,7 +236,7 @@ class Token
const mpfr_t* const mpfr_t*
float_value() const float_value() const
{ {
gcc_assert(this->classification_ == TOKEN_FLOAT); go_assert(this->classification_ == TOKEN_FLOAT);
return &this->u_.float_value; return &this->u_.float_value;
} }
...@@ -244,7 +244,7 @@ class Token ...@@ -244,7 +244,7 @@ class Token
const mpfr_t* const mpfr_t*
imaginary_value() const imaginary_value() const
{ {
gcc_assert(this->classification_ == TOKEN_IMAGINARY); go_assert(this->classification_ == TOKEN_IMAGINARY);
return &this->u_.float_value; return &this->u_.float_value;
} }
...@@ -252,7 +252,7 @@ class Token ...@@ -252,7 +252,7 @@ class Token
Operator Operator
op() const op() const
{ {
gcc_assert(this->classification_ == TOKEN_OPERATOR); go_assert(this->classification_ == TOKEN_OPERATOR);
return this->u_.op; return this->u_.op;
} }
......
...@@ -77,7 +77,7 @@ static Type* runtime_function_types[NUMBER_OF_RUNTIME_FUNCTION_TYPES]; ...@@ -77,7 +77,7 @@ static Type* runtime_function_types[NUMBER_OF_RUNTIME_FUNCTION_TYPES];
static Type* static Type*
runtime_function_type(Runtime_function_type bft) 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) if (runtime_function_types[bft] == NULL)
{ {
const source_location bloc = BUILTINS_LOCATION; const source_location bloc = BUILTINS_LOCATION;
...@@ -223,7 +223,7 @@ convert_to_runtime_function_type(Runtime_function_type bft, Expression* e, ...@@ -223,7 +223,7 @@ convert_to_runtime_function_type(Runtime_function_type bft, Expression* e,
return Expression::make_unsafe_cast(runtime_function_type(bft), e, loc); return Expression::make_unsafe_cast(runtime_function_type(bft), e, loc);
case RFT_TYPE: 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; return e;
} }
} }
...@@ -240,7 +240,7 @@ Runtime::convert_types(Gogo* gogo) ...@@ -240,7 +240,7 @@ Runtime::convert_types(Gogo* gogo)
if (t != NULL && t->named_type() != NULL) if (t != NULL && t->named_type() != NULL)
{ {
bool r = t->verify(); bool r = t->verify();
gcc_assert(r); go_assert(r);
t->named_type()->convert(gogo); t->named_type()->convert(gogo);
} }
} }
...@@ -279,7 +279,7 @@ runtime_function_declarations[Runtime::NUMBER_OF_FUNCTIONS]; ...@@ -279,7 +279,7 @@ runtime_function_declarations[Runtime::NUMBER_OF_FUNCTIONS];
Named_object* Named_object*
Runtime::runtime_declaration(Function code) 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) if (runtime_function_declarations[code] == NULL)
{ {
const Runtime_function* pb = &runtime_functions[code]; const Runtime_function* pb = &runtime_functions[code];
...@@ -339,11 +339,11 @@ Call_expression* ...@@ -339,11 +339,11 @@ Call_expression*
Runtime::make_call(Runtime::Function code, source_location loc, Runtime::make_call(Runtime::Function code, source_location loc,
int param_count, ...) int param_count, ...)
{ {
gcc_assert(code < Runtime::NUMBER_OF_FUNCTIONS); go_assert(code < Runtime::NUMBER_OF_FUNCTIONS);
const Runtime_function* pb = &runtime_functions[code]; 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])); <= sizeof(pb->parameter_types) / sizeof(pb->parameter_types[0]));
Named_object* no = runtime_declaration(code); Named_object* no = runtime_declaration(code);
......
...@@ -690,7 +690,7 @@ class Select_clauses ...@@ -690,7 +690,7 @@ class Select_clauses
: channel_(channel), val_(val), closed_(closed), var_(var), : channel_(channel), val_(val), closed_(closed), var_(var),
closedvar_(closedvar), statements_(statements), location_(location), closedvar_(closedvar), statements_(statements), location_(location),
is_send_(is_send), is_default_(is_default), is_lowered_(false) 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. // Traverse the select clause.
int int
...@@ -719,7 +719,7 @@ class Select_clauses ...@@ -719,7 +719,7 @@ class Select_clauses
bool bool
is_send() const is_send() const
{ {
gcc_assert(!this->is_default_); go_assert(!this->is_default_);
return this->is_send_; return this->is_send_;
} }
...@@ -792,7 +792,7 @@ class Select_statement : public Statement ...@@ -792,7 +792,7 @@ class Select_statement : public Statement
void void
add_clauses(Select_clauses* clauses) add_clauses(Select_clauses* clauses)
{ {
gcc_assert(this->clauses_ == NULL); go_assert(this->clauses_ == NULL);
this->clauses_ = clauses; this->clauses_ = clauses;
} }
...@@ -967,7 +967,7 @@ class For_statement : public Statement ...@@ -967,7 +967,7 @@ class For_statement : public Statement
void void
add_statements(Block* statements) add_statements(Block* statements)
{ {
gcc_assert(this->statements_ == NULL); go_assert(this->statements_ == NULL);
this->statements_ = statements; this->statements_ = statements;
} }
...@@ -1030,7 +1030,7 @@ class For_range_statement : public Statement ...@@ -1030,7 +1030,7 @@ class For_range_statement : public Statement
void void
add_statements(Block* statements) add_statements(Block* statements)
{ {
gcc_assert(this->statements_ == NULL); go_assert(this->statements_ == NULL);
this->statements_ = statements; this->statements_ = statements;
} }
...@@ -1267,7 +1267,7 @@ class Switch_statement : public Statement ...@@ -1267,7 +1267,7 @@ class Switch_statement : public Statement
void void
add_clauses(Case_clauses* clauses) add_clauses(Case_clauses* clauses)
{ {
gcc_assert(this->clauses_ == NULL); go_assert(this->clauses_ == NULL);
this->clauses_ = clauses; this->clauses_ = clauses;
} }
...@@ -1407,13 +1407,13 @@ class Type_switch_statement : public Statement ...@@ -1407,13 +1407,13 @@ class Type_switch_statement : public Statement
source_location location) source_location location)
: Statement(STATEMENT_TYPE_SWITCH, location), : Statement(STATEMENT_TYPE_SWITCH, location),
var_(var), expr_(expr), clauses_(NULL), break_label_(NULL) var_(var), expr_(expr), clauses_(NULL), break_label_(NULL)
{ gcc_assert(var == NULL || expr == NULL); } { go_assert(var == NULL || expr == NULL); }
// Add the clauses. // Add the clauses.
void void
add_clauses(Type_case_clauses* clauses) add_clauses(Type_case_clauses* clauses)
{ {
gcc_assert(this->clauses_ == NULL); go_assert(this->clauses_ == NULL);
this->clauses_ = clauses; this->clauses_ = clauses;
} }
......
...@@ -160,7 +160,7 @@ class Method ...@@ -160,7 +160,7 @@ class Method
Named_object* Named_object*
stub_object() const stub_object() const
{ {
gcc_assert(this->stub_ != NULL); go_assert(this->stub_ != NULL);
return this->stub_; return this->stub_;
} }
...@@ -168,7 +168,7 @@ class Method ...@@ -168,7 +168,7 @@ class Method
void void
set_stub_object(Named_object* no) set_stub_object(Named_object* no)
{ {
gcc_assert(this->stub_ == NULL); go_assert(this->stub_ == NULL);
this->stub_ = no; this->stub_ = no;
} }
...@@ -1167,7 +1167,7 @@ class Typed_identifier ...@@ -1167,7 +1167,7 @@ class Typed_identifier
void void
set_type(Type* type) 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; this->type_ = type;
} }
...@@ -1213,7 +1213,7 @@ class Typed_identifier_list ...@@ -1213,7 +1213,7 @@ class Typed_identifier_list
void void
set_type(size_t i, Type* type) 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); this->entries_[i].set_type(type);
} }
...@@ -1253,7 +1253,7 @@ class Typed_identifier_list ...@@ -1253,7 +1253,7 @@ class Typed_identifier_list
void void
resize(size_t c) 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)); this->entries_.resize(c, Typed_identifier("", NULL, UNKNOWN_LOCATION));
} }
...@@ -1777,7 +1777,7 @@ class Struct_field ...@@ -1777,7 +1777,7 @@ class Struct_field
const std::string& const std::string&
tag() const tag() const
{ {
gcc_assert(this->tag_ != NULL); go_assert(this->tag_ != NULL);
return *this->tag_; return *this->tag_;
} }
...@@ -2228,7 +2228,7 @@ class Channel_type : public Type ...@@ -2228,7 +2228,7 @@ class Channel_type : public Type
: Type(TYPE_CHANNEL), : Type(TYPE_CHANNEL),
may_send_(may_send), may_receive_(may_receive), may_send_(may_send), may_receive_(may_receive),
element_type_(element_type) element_type_(element_type)
{ gcc_assert(may_send || may_receive); } { go_assert(may_send || may_receive); }
// Whether this channel can send data. // Whether this channel can send data.
bool bool
...@@ -2312,7 +2312,7 @@ class Interface_type : public Type ...@@ -2312,7 +2312,7 @@ class Interface_type : public Type
Interface_type(Typed_identifier_list* methods, source_location location) Interface_type(Typed_identifier_list* methods, source_location location)
: Type(TYPE_INTERFACE), : Type(TYPE_INTERFACE),
methods_(methods), location_(location) methods_(methods), location_(location)
{ gcc_assert(methods == NULL || !methods->empty()); } { go_assert(methods == NULL || !methods->empty()); }
// The location where the interface type was defined. // The location where the interface type was defined.
source_location source_location
......
...@@ -27,7 +27,7 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported, ...@@ -27,7 +27,7 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
if (package == NULL) if (package == NULL)
{ {
gcc_assert(saw_errors()); go_assert(saw_errors());
return; return;
} }
...@@ -44,9 +44,9 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported, ...@@ -44,9 +44,9 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
} }
else else
{ {
gcc_assert(no->package() == package); go_assert(no->package() == package);
gcc_assert(no->is_type()); go_assert(no->is_type());
gcc_assert(no->type_value()->is_unsafe_pointer_type()); go_assert(no->type_value()->is_unsafe_pointer_type());
no->type_value()->set_is_visible(); no->type_value()->set_is_visible();
} }
Named_type* pointer_type = no->type_value(); Named_type* pointer_type = no->type_value();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment