diff options
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 499 |
1 files changed, 256 insertions, 243 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 6b45ebf..81525a7 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -8,6 +8,7 @@ #include "lex.h" #include "gogo.h" +#include "go-diagnostics.h" #include "types.h" #include "statements.h" #include "expressions.h" @@ -109,7 +110,7 @@ Parse::identifier_list(Typed_identifier_list* til) { if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return; } std::string name = @@ -172,7 +173,7 @@ Parse::qualified_ident(std::string* pname, Named_object** ppackage) const Token* token = this->peek_token(); if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return false; } @@ -191,7 +192,7 @@ Parse::qualified_ident(std::string* pname, Named_object** ppackage) Named_object* package = this->gogo_->lookup(name, NULL); if (package == NULL || !package->is_package()) { - error_at(this->location(), "expected package"); + go_error_at(this->location(), "expected package"); // We expect . IDENTIFIER; skip both. if (this->advance_token()->is_identifier()) this->advance_token(); @@ -203,7 +204,7 @@ Parse::qualified_ident(std::string* pname, Named_object** ppackage) token = this->advance_token(); if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return false; } @@ -211,7 +212,7 @@ Parse::qualified_ident(std::string* pname, Named_object** ppackage) if (name == "_") { - error_at(this->location(), "invalid use of %<_%>"); + go_error_at(this->location(), "invalid use of %<_%>"); name = Gogo::erroneous_name(); } @@ -269,13 +270,13 @@ Parse::type() else { if (!ret->is_error_type()) - error_at(this->location(), "expected %<)%>"); + go_error_at(this->location(), "expected %<)%>"); } return ret; } else { - error_at(token->location(), "expected type"); + go_error_at(token->location(), "expected type"); return Type::make_error_type(); } } @@ -329,9 +330,10 @@ Parse::type_name(bool issue_error) { Package* p = package->package_value(); const std::string& packname(p->package_name()); - error_at(location, "invalid reference to hidden type %<%s.%s%>", - Gogo::message_name(packname).c_str(), - Gogo::message_name(name).c_str()); + go_error_at(location, + "invalid reference to hidden type %<%s.%s%>", + Gogo::message_name(packname).c_str(), + Gogo::message_name(name).c_str()); issue_error = false; } } @@ -345,9 +347,9 @@ Parse::type_name(bool issue_error) else { const std::string& packname(package->package_value()->package_name()); - error_at(location, "reference to undefined identifier %<%s.%s%>", - Gogo::message_name(packname).c_str(), - Gogo::message_name(name).c_str()); + go_error_at(location, "reference to undefined identifier %<%s.%s%>", + Gogo::message_name(packname).c_str(), + Gogo::message_name(name).c_str()); issue_error = false; ok = false; } @@ -365,7 +367,7 @@ Parse::type_name(bool issue_error) if (!ok) { if (issue_error) - error_at(location, "expected type"); + go_error_at(location, "expected type"); return Type::make_error_type(); } @@ -405,14 +407,14 @@ Parse::array_type(bool may_use_ellipsis) } else { - error_at(this->location(), - "use of %<[...]%> outside of array literal"); + go_error_at(this->location(), + "use of %<[...]%> outside of array literal"); length = Expression::make_error(this->location()); this->advance_token(); } if (!this->peek_token()->is_op(OPERATOR_RSQUARE)) { - error_at(this->location(), "expected %<]%>"); + go_error_at(this->location(), "expected %<]%>"); return Type::make_error_type(); } this->advance_token(); @@ -436,7 +438,7 @@ Parse::map_type() go_assert(this->peek_token()->is_keyword(KEYWORD_MAP)); if (!this->advance_token()->is_op(OPERATOR_LSQUARE)) { - error_at(this->location(), "expected %<[%>"); + go_error_at(this->location(), "expected %<[%>"); return Type::make_error_type(); } this->advance_token(); @@ -445,7 +447,7 @@ Parse::map_type() if (!this->peek_token()->is_op(OPERATOR_RSQUARE)) { - error_at(this->location(), "expected %<]%>"); + go_error_at(this->location(), "expected %<]%>"); return Type::make_error_type(); } this->advance_token(); @@ -470,10 +472,10 @@ Parse::struct_type() Location token_loc = this->location(); if (this->peek_token()->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(token_loc, "unexpected semicolon or newline before %<{%>"); + go_error_at(token_loc, "unexpected semicolon or newline before %<{%>"); else { - error_at(this->location(), "expected %<{%>"); + go_error_at(this->location(), "expected %<{%>"); return Type::make_error_type(); } } @@ -487,7 +489,7 @@ Parse::struct_type() this->advance_token(); else if (!this->peek_token()->is_op(OPERATOR_RCURLY)) { - error_at(this->location(), "expected %<;%> or %<}%> or newline"); + go_error_at(this->location(), "expected %<;%> or %<}%> or newline"); if (!this->skip_past_error(OPERATOR_RCURLY)) return Type::make_error_type(); } @@ -506,8 +508,8 @@ Parse::struct_type() { if (pi->field_name() == pj->field_name() && !Gogo::is_sink_name(pi->field_name())) - error_at(pi->location(), "duplicate field name %<%s%>", - Gogo::message_name(pi->field_name()).c_str()); + go_error_at(pi->location(), "duplicate field name %<%s%>", + Gogo::message_name(pi->field_name()).c_str()); } } @@ -545,7 +547,7 @@ Parse::field_decl(Struct_field_list* sfl) } else { - error_at(this->location(), "expected field name"); + go_error_at(this->location(), "expected field name"); this->gogo_->mark_locals_used(); while (!token->is_op(OPERATOR_SEMICOLON) && !token->is_op(OPERATOR_RCURLY) @@ -561,7 +563,7 @@ Parse::field_decl(Struct_field_list* sfl) this->advance_token(); if (!this->peek_token()->is_identifier()) { - error_at(this->location(), "expected field name"); + go_error_at(this->location(), "expected field name"); this->gogo_->mark_locals_used(); while (!token->is_op(OPERATOR_SEMICOLON) && !token->is_op(OPERATOR_RCURLY) @@ -596,7 +598,7 @@ Parse::field_decl(Struct_field_list* sfl) token = this->peek_token(); if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return; } std::string name = @@ -657,7 +659,7 @@ Parse::channel_type() { if (!this->advance_token()->is_keyword(KEYWORD_CHAN)) { - error_at(this->location(), "expected %<chan%>"); + go_error_at(this->location(), "expected %<chan%>"); return Type::make_error_type(); } send = false; @@ -679,13 +681,13 @@ Parse::channel_type() { token = this->peek_token(); if (token->is_op(OPERATOR_RCURLY)) - error_at(this->location(), "unexpected %<}%> in channel type"); + go_error_at(this->location(), "unexpected %<}%> in channel type"); else if (token->is_op(OPERATOR_RPAREN)) - error_at(this->location(), "unexpected %<)%> in channel type"); + go_error_at(this->location(), "unexpected %<)%> in channel type"); else if (token->is_op(OPERATOR_COMMA)) - error_at(this->location(), "unexpected comma in channel type"); + go_error_at(this->location(), "unexpected comma in channel type"); else - error_at(this->location(), "expected channel element type"); + go_error_at(this->location(), "expected channel element type"); return Type::make_error_type(); } @@ -710,11 +712,11 @@ Parse::check_signature_names(const Typed_identifier_list* params, std::pair<Parse::Names::iterator, bool> ins = names->insert(val); if (!ins.second) { - error_at(p->location(), "redefinition of %qs", - Gogo::message_name(p->name()).c_str()); - inform(ins.first->second->location(), - "previous definition of %qs was here", - Gogo::message_name(p->name()).c_str()); + go_error_at(p->location(), "redefinition of %qs", + Gogo::message_name(p->name()).c_str()); + go_inform(ins.first->second->location(), + "previous definition of %qs was here", + Gogo::message_name(p->name()).c_str()); } } } @@ -770,7 +772,7 @@ Parse::parameters(Typed_identifier_list** pparams, bool* is_varargs) if (!this->peek_token()->is_op(OPERATOR_LPAREN)) { - error_at(this->location(), "expected %<(%>"); + go_error_at(this->location(), "expected %<(%>"); return false; } @@ -790,7 +792,7 @@ Parse::parameters(Typed_identifier_list** pparams, bool* is_varargs) if (!token->is_op(OPERATOR_RPAREN)) { - error_at(this->location(), "expected %<)%>"); + go_error_at(this->location(), "expected %<)%>"); return false; } this->advance_token(); @@ -929,7 +931,8 @@ Parse::parameter_list(bool* is_varargs) type = this->type(); else { - error_at(this->location(), "%<...%> only permits one name"); + go_error_at(this->location(), + "%<...%> only permits one name"); saw_error = true; this->advance_token(); type = this->type(); @@ -960,8 +963,8 @@ Parse::parameter_list(bool* is_varargs) type = Type::make_forward_declaration(no); else { - error_at(p->location(), "expected %<%s%> to be a type", - Gogo::message_name(p->name()).c_str()); + go_error_at(p->location(), "expected %<%s%> to be a type", + Gogo::message_name(p->name()).c_str()); saw_error = true; type = Type::make_error_type(); } @@ -985,7 +988,7 @@ Parse::parameter_list(bool* is_varargs) break; if (is_varargs != NULL && *is_varargs) { - error_at(this->location(), "%<...%> must be last parameter"); + go_error_at(this->location(), "%<...%> must be last parameter"); saw_error = true; } this->parameter_decl(parameters_have_names, ret, is_varargs, &mix_error, @@ -993,7 +996,7 @@ Parse::parameter_list(bool* is_varargs) } if (mix_error) { - error_at(location, "invalid named/anonymous mix"); + go_error_at(location, "invalid named/anonymous mix"); saw_error = true; } if (saw_error) @@ -1024,7 +1027,7 @@ Parse::parameter_decl(bool parameters_have_names, else { if (is_varargs == NULL) - error_at(this->location(), "invalid use of %<...%>"); + go_error_at(this->location(), "invalid use of %<...%>"); else *is_varargs = true; this->advance_token(); @@ -1073,12 +1076,12 @@ Parse::parameter_decl(bool parameters_have_names, { if (is_varargs == NULL) { - error_at(this->location(), "invalid use of %<...%>"); + go_error_at(this->location(), "invalid use of %<...%>"); *saw_error = true; } else if (new_count > orig_count + 1) { - error_at(this->location(), "%<...%> only permits one name"); + go_error_at(this->location(), "%<...%> only permits one name"); *saw_error = true; } else @@ -1129,10 +1132,10 @@ Parse::block() Location loc = this->location(); if (this->peek_token()->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(loc, "unexpected semicolon or newline before %<{%>"); + go_error_at(loc, "unexpected semicolon or newline before %<{%>"); else { - error_at(this->location(), "expected %<{%>"); + go_error_at(this->location(), "expected %<{%>"); return Linemap::unknown_location(); } } @@ -1146,7 +1149,7 @@ Parse::block() if (!token->is_op(OPERATOR_RCURLY)) { if (!token->is_eof() || !saw_errors()) - error_at(this->location(), "expected %<}%>"); + go_error_at(this->location(), "expected %<}%>"); this->gogo_->mark_locals_used(); @@ -1193,10 +1196,10 @@ Parse::interface_type(bool record) Location token_loc = this->location(); if (this->peek_token()->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(token_loc, "unexpected semicolon or newline before %<{%>"); + go_error_at(token_loc, "unexpected semicolon or newline before %<{%>"); else { - error_at(this->location(), "expected %<{%>"); + go_error_at(this->location(), "expected %<{%>"); return Type::make_error_type(); } } @@ -1214,7 +1217,7 @@ Parse::interface_type(bool record) } if (!this->peek_token()->is_op(OPERATOR_RCURLY)) { - error_at(this->location(), "expected %<}%>"); + go_error_at(this->location(), "expected %<}%>"); while (!this->advance_token()->is_op(OPERATOR_RCURLY)) { if (this->peek_token()->is_eof()) @@ -1250,7 +1253,7 @@ Parse::method_spec(Typed_identifier_list* methods) const Token* token = this->peek_token(); if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return; } @@ -1262,7 +1265,8 @@ Parse::method_spec(Typed_identifier_list* methods) { // This is a MethodName. if (name == "_") - error_at(this->location(), "methods must have a unique non-blank name"); + go_error_at(this->location(), + "methods must have a unique non-blank name"); name = this->gogo_->pack_hidden_name(name, is_exported); Type* type = this->signature(NULL, location); if (type == NULL) @@ -1279,10 +1283,10 @@ Parse::method_spec(Typed_identifier_list* methods) && !this->peek_token()->is_op(OPERATOR_RCURLY))) { if (this->peek_token()->is_op(OPERATOR_COMMA)) - error_at(this->location(), - "name list not allowed in interface type"); + go_error_at(this->location(), + "name list not allowed in interface type"); else - error_at(location, "expected signature or type name"); + go_error_at(location, "expected signature or type name"); this->gogo_->mark_locals_used(); token = this->peek_token(); while (!token->is_eof() @@ -1307,8 +1311,8 @@ Parse::declaration() unsigned int pragmas = this->lex_->get_and_clear_pragmas(); if (pragmas != 0 && !token->is_keyword(KEYWORD_FUNC)) - warning_at(token->location(), 0, - "ignoring magic comment before non-function"); + go_warning_at(token->location(), 0, + "ignoring magic comment before non-function"); if (token->is_keyword(KEYWORD_CONST)) this->const_decl(); @@ -1320,7 +1324,7 @@ Parse::declaration() this->function_decl(pragmas); else { - error_at(this->location(), "expected declaration"); + go_error_at(this->location(), "expected declaration"); this->advance_token(); } } @@ -1343,7 +1347,7 @@ Parse::decl(void (Parse::*pfn)(void*), void* varg) if (this->peek_token()->is_eof()) { if (!saw_errors()) - error_at(this->location(), "unexpected end of file"); + go_error_at(this->location(), "unexpected end of file"); return; } @@ -1356,7 +1360,7 @@ Parse::decl(void (Parse::*pfn)(void*), void* varg) this->list(pfn, varg, true); if (!this->peek_token()->is_op(OPERATOR_RPAREN)) { - error_at(this->location(), "missing %<)%>"); + go_error_at(this->location(), "missing %<)%>"); while (!this->advance_token()->is_op(OPERATOR_RPAREN)) { if (this->peek_token()->is_eof()) @@ -1382,7 +1386,7 @@ Parse::list(void (Parse::*pfn)(void*), void* varg, bool follow_is_paren) || this->peek_token()->is_op(OPERATOR_COMMA)) { if (this->peek_token()->is_op(OPERATOR_COMMA)) - error_at(this->location(), "unexpected comma"); + go_error_at(this->location(), "unexpected comma"); if (this->advance_token()->is_op(follow)) break; (this->*pfn)(varg); @@ -1413,7 +1417,8 @@ Parse::const_decl() this->advance_token(); else if (!this->peek_token()->is_op(OPERATOR_RPAREN)) { - error_at(this->location(), "expected %<;%> or %<)%> or newline"); + go_error_at(this->location(), + "expected %<;%> or %<)%> or newline"); if (!this->skip_past_error(OPERATOR_RPAREN)) return; } @@ -1446,7 +1451,7 @@ Parse::const_spec(Type** last_type, Expression_list** last_expr_list) { if (*last_expr_list == NULL) { - error_at(this->location(), "expected %<=%>"); + go_error_at(this->location(), "expected %<=%>"); return; } type = *last_type; @@ -1473,7 +1478,7 @@ Parse::const_spec(Type** last_type, Expression_list** last_expr_list) { if (pe == expr_list->end()) { - error_at(this->location(), "not enough initializers"); + go_error_at(this->location(), "not enough initializers"); return; } if (type != NULL) @@ -1493,7 +1498,7 @@ Parse::const_spec(Type** last_type, Expression_list** last_expr_list) } } if (pe != expr_list->end()) - error_at(this->location(), "too many initializers"); + go_error_at(this->location(), "too many initializers"); this->increment_iota(); @@ -1518,7 +1523,7 @@ Parse::type_spec(void*) const Token* token = this->peek_token(); if (!token->is_identifier()) { - error_at(this->location(), "expected identifier"); + go_error_at(this->location(), "expected identifier"); return; } std::string name = token->identifier(); @@ -1547,8 +1552,8 @@ Parse::type_spec(void*) type = this->type(); else { - error_at(this->location(), - "unexpected semicolon or newline in type declaration"); + go_error_at(this->location(), + "unexpected semicolon or newline in type declaration"); type = Type::make_error_type(); this->advance_token(); } @@ -1570,7 +1575,7 @@ Parse::type_spec(void*) && (ftype->forward_declaration_type()->named_object() == named_type)) { - error_at(location, "invalid recursive type"); + go_error_at(location, "invalid recursive type"); type = Type::make_error_type(); } @@ -1669,7 +1674,7 @@ Parse::init_vars(const Typed_identifier_list* til, Type* type, if (init != NULL && init->size() != til->size()) { if (init->empty() || !init->front()->is_error_expression()) - error_at(location, "wrong number of initializations"); + go_error_at(location, "wrong number of initializations"); init = NULL; if (type == NULL) type = Type::make_error_type(); @@ -1701,7 +1706,7 @@ Parse::init_vars(const Typed_identifier_list* til, Type* type, if (init != NULL) go_assert(pexpr == init->end()); if (is_coloneq && !any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); this->finish_init_vars(vars, vals, location); } @@ -1761,7 +1766,7 @@ Parse::init_vars_from_call(const Typed_identifier_list* vars, Type* type, } if (is_coloneq && !any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); this->finish_init_vars(ivars, ivals, location); @@ -1804,7 +1809,7 @@ Parse::init_vars_from_map(const Typed_identifier_list* vars, Type* type, Expression* present_var = Expression::make_var_reference(no, location); if (is_coloneq && !any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); Statement* s = Statement::make_tuple_map_assignment(val_var, present_var, index, location); @@ -1869,7 +1874,7 @@ Parse::init_vars_from_receive(const Typed_identifier_list* vars, Type* type, Expression* received_var = Expression::make_var_reference(no, location); if (is_coloneq && !any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); Statement* s = Statement::make_tuple_receive_assignment(val_var, received_var, @@ -1940,7 +1945,7 @@ Parse::init_vars_from_type_guard(const Typed_identifier_list* vars, location); if (is_coloneq && !any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); if (!this->gogo_->in_global_scope()) this->gogo_->add_statement(s); @@ -2133,8 +2138,8 @@ Parse::simple_var_decl_or_assignment(const std::string& name, id = this->gogo_->pack_hidden_name(id, is_id_exported); ins = uniq_idents.insert(id); if (!ins.second && !Gogo::is_sink_name(id)) - error_at(id_location, "multiple assignments to %s", - Gogo::message_name(id).c_str()); + go_error_at(id_location, "multiple assignments to %s", + Gogo::message_name(id).c_str()); til.push_back(Typed_identifier(id, NULL, location)); } else @@ -2187,7 +2192,7 @@ Parse::simple_var_decl_or_assignment(const std::string& name, const Token* token = this->advance_token(); if (!dup_name.empty()) - error_at(dup_loc, "multiple assignments to %s", dup_name.c_str()); + go_error_at(dup_loc, "multiple assignments to %s", dup_name.c_str()); if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE)) { @@ -2259,7 +2264,7 @@ Parse::function_decl(unsigned int pragmas) if (!token->is_identifier()) { - error_at(this->location(), "expected function name"); + go_error_at(this->location(), "expected function name"); return; } @@ -2277,19 +2282,19 @@ Parse::function_decl(unsigned int pragmas) { if (!this->advance_token()->is_op(OPERATOR_LPAREN)) { - error_at(this->location(), "expected %<(%>"); + go_error_at(this->location(), "expected %<(%>"); return; } token = this->advance_token(); if (!token->is_string()) { - error_at(this->location(), "expected string"); + go_error_at(this->location(), "expected string"); return; } std::string asm_name = token->string_value(); if (!this->advance_token()->is_op(OPERATOR_RPAREN)) { - error_at(this->location(), "expected %<)%>"); + go_error_at(this->location(), "expected %<)%>"); return; } this->advance_token(); @@ -2306,8 +2311,8 @@ Parse::function_decl(unsigned int pragmas) { Location semi_loc = this->location(); if (this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(this->location(), - "unexpected semicolon or newline before %<{%>"); + go_error_at(this->location(), + "unexpected semicolon or newline before %<{%>"); else this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON, semi_loc)); @@ -2347,28 +2352,28 @@ Parse::function_decl(unsigned int pragmas) { if (pragma_check[i].decl_ok) continue; - warning_at(location, 0, - ("ignoring magic //go:%s comment " - "before declaration"), - pragma_check[i].name); + go_warning_at(location, 0, + ("ignoring magic //go:%s comment " + "before declaration"), + pragma_check[i].name); } else if (rec == NULL) { if (pragma_check[i].func_ok) continue; - warning_at(location, 0, - ("ignoring magic //go:%s comment " - "before function definition"), - pragma_check[i].name); + go_warning_at(location, 0, + ("ignoring magic //go:%s comment " + "before function definition"), + pragma_check[i].name); } else { if (pragma_check[i].method_ok) continue; - warning_at(location, 0, - ("ignoring magic //go:%s comment " - "before method definition"), - pragma_check[i].name); + go_warning_at(location, 0, + ("ignoring magic //go:%s comment " + "before method definition"), + pragma_check[i].name); } pragmas &= ~ pragma_check[i].bit; @@ -2445,12 +2450,12 @@ Parse::receiver() return NULL; else if (til == NULL || til->empty()) { - error_at(location, "method has no receiver"); + go_error_at(location, "method has no receiver"); return NULL; } else if (til->size() > 1) { - error_at(location, "method has multiple receivers"); + go_error_at(location, "method has multiple receivers"); return NULL; } else @@ -2489,7 +2494,7 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) if (!this->advance_token()->is_op(OPERATOR_DOT) || !this->advance_token()->is_identifier()) { - error_at(location, "unexpected reference to package"); + go_error_at(location, "unexpected reference to package"); return Expression::make_error(location); } package = named_object->package_value(); @@ -2509,9 +2514,9 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) && !named_object->type_value()->is_visible()) { go_assert(package != NULL); - error_at(location, "invalid reference to hidden type %<%s.%s%>", - Gogo::message_name(package->package_name()).c_str(), - Gogo::message_name(id).c_str()); + go_error_at(location, "invalid reference to hidden type %<%s.%s%>", + Gogo::message_name(package->package_name()).c_str(), + Gogo::message_name(id).c_str()); return Expression::make_error(location); } @@ -2523,14 +2528,14 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) std::string n1 = Gogo::message_name(package->package_name()); std::string n2 = Gogo::message_name(id); if (!is_exported) - error_at(location, - ("invalid reference to unexported identifier " - "%<%s.%s%>"), - n1.c_str(), n2.c_str()); + go_error_at(location, + ("invalid reference to unexported identifier " + "%<%s.%s%>"), + n1.c_str(), n2.c_str()); else - error_at(location, - "reference to undefined identifier %<%s.%s%>", - n1.c_str(), n2.c_str()); + go_error_at(location, + "reference to undefined identifier %<%s.%s%>", + n1.c_str(), n2.c_str()); return Expression::make_error(location); } @@ -2567,7 +2572,7 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) return Expression::make_sink(location); else { - error_at(location, "cannot use _ as value"); + go_error_at(location, "cannot use _ as value"); return Expression::make_error(location); } case Named_object::NAMED_OBJECT_FUNC: @@ -2652,7 +2657,7 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) ret = this->expression(PRECEDENCE_NORMAL, may_be_sink, true, NULL, NULL); if (!this->peek_token()->is_op(OPERATOR_RPAREN)) - error_at(this->location(), "missing %<)%>"); + go_error_at(this->location(), "missing %<)%>"); else this->advance_token(); if (is_parenthesized != NULL) @@ -2672,7 +2677,7 @@ Parse::operand(bool may_be_sink, bool* is_parenthesized) break; } - error_at(this->location(), "expected operand"); + go_error_at(this->location(), "expected operand"); return Expression::make_error(this->location()); } @@ -2877,10 +2882,11 @@ Parse::composite_lit(Type* type, int depth, Location location) else { if (token->is_op(OPERATOR_SEMICOLON)) - error_at(this->location(), - "need trailing comma before newline in composite literal"); + go_error_at(this->location(), + ("need trailing comma before newline " + "in composite literal")); else - error_at(this->location(), "expected %<,%> or %<}%>"); + go_error_at(this->location(), "expected %<,%> or %<}%>"); this->gogo_->mark_locals_used(); int depth = 0; @@ -3073,13 +3079,13 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit, Type* t = ret->type(); if (t->named_type() != NULL || t->forward_declaration_type() != NULL) - error_at(start_loc, - _("parentheses required around this composite literal " - "to avoid parsing ambiguity")); + go_error_at(start_loc, + _("parentheses required around this composite " + "literal to avoid parsing ambiguity")); } else if (operand_is_parenthesized) - error_at(start_loc, - "cannot parenthesize type in composite literal"); + go_error_at(start_loc, + "cannot parenthesize type in composite literal"); ret = this->composite_lit(ret->type(), 0, ret->location()); } else if (this->peek_token()->is_op(OPERATOR_LPAREN)) @@ -3093,12 +3099,12 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit, this->advance_token(); if (this->peek_token()->is_op(OPERATOR_ELLIPSIS)) { - error_at(this->location(), - "invalid use of %<...%> in type conversion"); + go_error_at(this->location(), + "invalid use of %<...%> in type conversion"); this->advance_token(); } if (!this->peek_token()->is_op(OPERATOR_RPAREN)) - error_at(this->location(), "expected %<)%>"); + go_error_at(this->location(), "expected %<)%>"); else this->advance_token(); if (expr->is_error_expression()) @@ -3110,8 +3116,8 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit, && t->array_type()->length() != NULL && t->array_type()->length()->is_nil_expression()) { - error_at(ret->location(), - "use of %<[...]%> outside of array literal"); + go_error_at(ret->location(), + "use of %<[...]%> outside of array literal"); ret = Expression::make_error(loc); } else @@ -3177,7 +3183,7 @@ Parse::selector(Expression* left, bool* is_type_switch) token->is_identifier_exported()); if (token->identifier() == "_") { - error_at(this->location(), "invalid use of %<_%>"); + go_error_at(this->location(), "invalid use of %<_%>"); name = Gogo::erroneous_name(); } this->advance_token(); @@ -3195,14 +3201,14 @@ Parse::selector(Expression* left, bool* is_type_switch) *is_type_switch = true; else { - error_at(this->location(), - "use of %<.(type)%> outside type switch"); + go_error_at(this->location(), + "use of %<.(type)%> outside type switch"); type = Type::make_error_type(); } this->advance_token(); } if (!this->peek_token()->is_op(OPERATOR_RPAREN)) - error_at(this->location(), "missing %<)%>"); + go_error_at(this->location(), "missing %<)%>"); else this->advance_token(); if (is_type_switch != NULL && *is_type_switch) @@ -3211,7 +3217,7 @@ Parse::selector(Expression* left, bool* is_type_switch) } else { - error_at(this->location(), "expected identifier or %<(%>"); + go_error_at(this->location(), "expected identifier or %<(%>"); return left; } } @@ -3240,7 +3246,8 @@ Parse::index(Expression* expr) end = Expression::make_nil(this->location()); else if (this->peek_token()->is_op(OPERATOR_COLON)) { - error_at(this->location(), "middle index required in 3-index slice"); + go_error_at(this->location(), + "middle index required in 3-index slice"); end = Expression::make_error(this->location()); } else @@ -3252,14 +3259,15 @@ Parse::index(Expression* expr) { if (this->advance_token()->is_op(OPERATOR_RSQUARE)) { - error_at(this->location(), "final index required in 3-index slice"); + go_error_at(this->location(), + "final index required in 3-index slice"); cap = Expression::make_error(this->location()); } else cap = this->expression(PRECEDENCE_NORMAL, false, true, NULL, NULL); } if (!this->peek_token()->is_op(OPERATOR_RSQUARE)) - error_at(this->location(), "missing %<]%>"); + go_error_at(this->location(), "missing %<]%>"); else this->advance_token(); return Expression::make_index(expr, start, end, cap, location); @@ -3289,7 +3297,7 @@ Parse::call(Expression* func) token = this->advance_token(); if (!token->is_op(OPERATOR_RPAREN)) { - error_at(this->location(), "missing %<)%>"); + go_error_at(this->location(), "missing %<)%>"); if (!this->skip_past_error(OPERATOR_RPAREN)) return Expression::make_error(this->location()); } @@ -3356,7 +3364,7 @@ Parse::id_to_expression(const std::string& name, Location location, case Named_object::NAMED_OBJECT_ERRONEOUS: return Expression::make_error(location); default: - error_at(this->location(), "unexpected type of identifier"); + go_error_at(this->location(), "unexpected type of identifier"); return Expression::make_error(location); } } @@ -3561,7 +3569,7 @@ Parse::unary_expr(bool may_be_sink, bool may_be_composite_lit, if (ct == NULL) { // This is probably impossible. - error_at(location, "expected channel type"); + go_error_at(location, "expected channel type"); return Expression::make_error(location); } else if (ct->may_receive()) @@ -3633,7 +3641,7 @@ Parse::reassociate_chan_direction(Channel_type *ct, Location location) Channel_type* ele = ct->element_type()->channel_type(); if (ele == NULL) { - error_at(location, "parse error"); + go_error_at(location, "parse error"); return Type::make_error_type(); } Type* sub = ele; @@ -3702,7 +3710,7 @@ Parse::statement(Label* label) this->for_stat(label); break; default: - error_at(this->location(), "expected statement"); + go_error_at(this->location(), "expected statement"); this->advance_token(); break; } @@ -3751,7 +3759,7 @@ Parse::statement(Label* label) break; default: - error_at(this->location(), "expected statement"); + go_error_at(this->location(), "expected statement"); this->advance_token(); break; } @@ -3847,7 +3855,7 @@ Parse::labeled_stmt(const std::string& label_name, Location location) if (label != NULL) label->set_is_used(); - error_at(location, "missing statement after label"); + go_error_at(location, "missing statement after label"); this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON, location)); return; @@ -3960,7 +3968,7 @@ Parse::simple_stat(bool may_be_composite_lit, bool* return_exp, if (token->is_op(OPERATOR_COLONEQ)) { if (!exp->is_error_expression()) - error_at(token->location(), "non-name on left side of %<:=%>"); + go_error_at(token->location(), "non-name on left side of %<:=%>"); this->gogo_->mark_locals_used(); while (!token->is_op(OPERATOR_SEMICOLON) && !token->is_eof()) @@ -3997,7 +4005,7 @@ Parse::statement_list() else { if (!this->peek_token()->is_eof() || !saw_errors()) - error_at(this->location(), "expected %<;%> or %<}%> or newline"); + go_error_at(this->location(), "expected %<;%> or %<}%> or newline"); if (!this->skip_past_error(OPERATOR_RCURLY)) return; } @@ -4104,7 +4112,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, && !token->is_op(OPERATOR_ANDEQ) && !token->is_op(OPERATOR_BITCLEAREQ)) { - error_at(this->location(), "expected assignment operator"); + go_error_at(this->location(), "expected assignment operator"); return; } Operator op = token->op(); @@ -4118,7 +4126,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, if (p_range_clause != NULL && token->is_keyword(KEYWORD_RANGE)) { if (op != OPERATOR_EQ) - error_at(this->location(), "range clause requires %<=%>"); + go_error_at(this->location(), "range clause requires %<=%>"); this->range_clause_expr(lhs, p_range_clause); return; } @@ -4136,7 +4144,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, if ((*pe)->is_error_expression()) return; if (op != OPERATOR_EQ && (*pe)->is_sink_expression()) - error_at((*pe)->location(), "cannot use _ as value"); + go_error_at((*pe)->location(), "cannot use _ as value"); } for (Expression_list::const_iterator pe = vals->begin(); pe != vals->end(); @@ -4156,7 +4164,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, if (lhs->size() > 1) { if (op != OPERATOR_EQ) - error_at(location, "multiple values only permitted with %<=%>"); + go_error_at(location, "multiple values only permitted with %<=%>"); s = Statement::make_tuple_assignment(lhs, vals, location); } else @@ -4176,7 +4184,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, && (call = (*vals->begin())->call_expression()) != NULL) { if (op != OPERATOR_EQ) - error_at(location, "multiple results only permitted with %<=%>"); + go_error_at(location, "multiple results only permitted with %<=%>"); call->set_expected_result_count(lhs->size()); delete vals; vals = new Expression_list; @@ -4190,7 +4198,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, && (map_index = (*vals->begin())->index_expression()) != NULL) { if (op != OPERATOR_EQ) - error_at(location, "two values from map requires %<=%>"); + go_error_at(location, "two values from map requires %<=%>"); Expression* val = lhs->front(); Expression* present = lhs->back(); Statement* s = Statement::make_tuple_map_assignment(val, present, @@ -4202,7 +4210,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, && (receive = (*vals->begin())->receive_expression()) != NULL) { if (op != OPERATOR_EQ) - error_at(location, "two values from receive requires %<=%>"); + go_error_at(location, "two values from receive requires %<=%>"); Expression* val = lhs->front(); Expression* success = lhs->back(); Expression* channel = receive->channel(); @@ -4216,7 +4224,7 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, && (type_guard = (*vals->begin())->type_guard_expression()) != NULL) { if (op != OPERATOR_EQ) - error_at(location, "two values from type guard requires %<=%>"); + go_error_at(location, "two values from type guard requires %<=%>"); Expression* val = lhs->front(); Expression* ok = lhs->back(); Expression* expr = type_guard->expr(); @@ -4228,7 +4236,8 @@ Parse::tuple_assignment(Expression_list* lhs, bool may_be_composite_lit, } else { - error_at(location, "number of variables does not match number of values"); + go_error_at(location, ("number of variables does not " + "match number of values")); } } @@ -4252,7 +4261,7 @@ Parse::go_or_defer_stat() Call_expression* call_expr = expr->call_expression(); if (is_parenthesized || call_expr == NULL) { - error_at(expr_location, "argument to go/defer must be function call"); + go_error_at(expr_location, "argument to go/defer must be function call"); return; } @@ -4295,8 +4304,8 @@ Parse::return_stat() if (no == NULL) go_assert(saw_errors()); else if (!no->is_result_variable()) - error_at(location, "%qs is shadowed during return", - (*p)->message_name().c_str()); + go_error_at(location, "%qs is shadowed during return", + (*p)->message_name().c_str()); } } } @@ -4334,19 +4343,19 @@ Parse::if_stat() else if (saw_simple_stat) { if (saw_send_stmt) - error_at(this->location(), - ("send statement used as value; " - "use select for non-blocking send")); + go_error_at(this->location(), + ("send statement used as value; " + "use select for non-blocking send")); else - error_at(this->location(), - "expected %<;%> after statement in if expression"); + go_error_at(this->location(), + "expected %<;%> after statement in if expression"); if (!this->expression_may_start_here()) cond = Expression::make_error(this->location()); } if (cond == NULL && this->peek_token()->is_op(OPERATOR_LCURLY)) { - error_at(this->location(), - "missing condition in if statement"); + go_error_at(this->location(), + "missing condition in if statement"); cond = Expression::make_error(this->location()); } if (cond == NULL) @@ -4358,7 +4367,7 @@ Parse::if_stat() { Location semi_loc = this->location(); if (this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(semi_loc, "missing %<{%> after if clause"); + go_error_at(semi_loc, "missing %<{%> after if clause"); // Otherwise we will get an error when we call this->block // below. } @@ -4372,7 +4381,7 @@ Parse::if_stat() { Location semi_loc = this->location(); if (this->advance_token()->is_keyword(KEYWORD_ELSE)) - error_at(this->location(), + go_error_at(this->location(), "unexpected semicolon or newline before %<else%>"); else this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON, @@ -4390,7 +4399,7 @@ Parse::if_stat() this->block(); else { - error_at(this->location(), "expected %<if%> or %<{%>"); + go_error_at(this->location(), "expected %<if%> or %<{%>"); this->statement(NULL); } else_block = this->gogo_->finish_block(this->location()); @@ -4444,12 +4453,12 @@ Parse::switch_stat(Label* label) else if (saw_simple_stat) { if (saw_send_stmt) - error_at(this->location(), - ("send statement used as value; " - "use select for non-blocking send")); + go_error_at(this->location(), + ("send statement used as value; " + "use select for non-blocking send")); else - error_at(this->location(), - "expected %<;%> after statement in switch expression"); + go_error_at(this->location(), + "expected %<;%> after statement in switch expression"); } if (!this->peek_token()->is_op(OPERATOR_LCURLY)) { @@ -4482,7 +4491,8 @@ Parse::switch_stat(Label* label) if (switch_val == NULL || !switch_val->is_error_expression()) { - error_at(id_loc, "expected type switch assignment"); + go_error_at(id_loc, + "expected type switch assignment"); switch_val = Expression::make_error(id_loc); } } @@ -4507,10 +4517,10 @@ Parse::switch_stat(Label* label) Location token_loc = this->location(); if (this->peek_token()->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(token_loc, "missing %<{%> after switch clause"); + go_error_at(token_loc, "missing %<{%> after switch clause"); else if (this->peek_token()->is_op(OPERATOR_COLONEQ)) { - error_at(token_loc, "invalid variable name"); + go_error_at(token_loc, "invalid variable name"); this->advance_token(); this->expression(PRECEDENCE_NORMAL, false, false, &type_switch.found, NULL); @@ -4530,7 +4540,7 @@ Parse::switch_stat(Label* label) } else { - error_at(this->location(), "expected %<{%>"); + go_error_at(this->location(), "expected %<{%>"); if (have_type_switch_block) this->gogo_->add_block(this->gogo_->finish_block(this->location()), location); @@ -4577,7 +4587,7 @@ Parse::expr_switch_body(Label* label, Expression* switch_val, if (this->peek_token()->is_eof()) { if (!saw_errors()) - error_at(this->location(), "missing %<}%>"); + go_error_at(this->location(), "missing %<}%>"); return NULL; } this->expr_case_clause(case_clauses, &saw_default); @@ -4605,7 +4615,7 @@ Parse::expr_case_clause(Case_clauses* clauses, bool* saw_default) if (!this->peek_token()->is_op(OPERATOR_COLON)) { if (!saw_errors()) - error_at(this->location(), "expected %<:%>"); + go_error_at(this->location(), "expected %<:%>"); return; } else @@ -4627,14 +4637,15 @@ Parse::expr_case_clause(Case_clauses* clauses, bool* saw_default) if (this->advance_token()->is_op(OPERATOR_SEMICOLON)) this->advance_token(); if (this->peek_token()->is_op(OPERATOR_RCURLY)) - error_at(fallthrough_loc, _("cannot fallthrough final case in switch")); + go_error_at(fallthrough_loc, + _("cannot fallthrough final case in switch")); } if (is_default) { if (*saw_default) { - error_at(location, "multiple defaults in switch"); + go_error_at(location, "multiple defaults in switch"); return; } *saw_default = true; @@ -4664,7 +4675,7 @@ Parse::expr_switch_case(bool* is_default) else { if (!saw_errors()) - error_at(this->location(), "expected %<case%> or %<default%>"); + go_error_at(this->location(), "expected %<case%> or %<default%>"); if (!token->is_op(OPERATOR_RCURLY)) this->advance_token(); return NULL; @@ -4684,8 +4695,8 @@ Parse::type_switch_body(Label* label, const Type_switch& type_switch, { if (Gogo::is_sink_name(var_name)) { - error_at(type_switch.location, - "no new variables on left side of %<:=%>"); + go_error_at(type_switch.location, + "no new variables on left side of %<:=%>"); var_name.clear(); } else @@ -4709,7 +4720,7 @@ Parse::type_switch_body(Label* label, const Type_switch& type_switch, { if (this->peek_token()->is_eof()) { - error_at(this->location(), "missing %<}%>"); + go_error_at(this->location(), "missing %<}%>"); return NULL; } this->type_case_clause(var_name, init, case_clauses, &saw_default, @@ -4737,8 +4748,8 @@ Parse::type_switch_body(Label* label, const Type_switch& type_switch, } } if (!used) - error_at(type_switch.location, "%qs declared and not used", - Gogo::message_name(var_name).c_str()); + go_error_at(type_switch.location, "%qs declared and not used", + Gogo::message_name(var_name).c_str()); } return statement; } @@ -4759,7 +4770,7 @@ Parse::type_case_clause(const std::string& var_name, Expression* init, this->type_switch_case(&types, &is_default); if (!this->peek_token()->is_op(OPERATOR_COLON)) - error_at(this->location(), "expected %<:%>"); + go_error_at(this->location(), "expected %<:%>"); else this->advance_token(); @@ -4789,8 +4800,8 @@ Parse::type_case_clause(const std::string& var_name, Expression* init, if (this->peek_token()->is_keyword(KEYWORD_FALLTHROUGH)) { - error_at(this->location(), - "fallthrough is not permitted in a type switch"); + go_error_at(this->location(), + "fallthrough is not permitted in a type switch"); if (this->advance_token()->is_op(OPERATOR_SEMICOLON)) this->advance_token(); } @@ -4800,7 +4811,7 @@ Parse::type_case_clause(const std::string& var_name, Expression* init, go_assert(types.empty()); if (*saw_default) { - error_at(location, "multiple defaults in type switch"); + go_error_at(location, "multiple defaults in type switch"); return; } *saw_default = true; @@ -4858,7 +4869,7 @@ Parse::type_switch_case(std::vector<Type*>* types, bool* is_default) } else { - error_at(this->location(), "expected %<case%> or %<default%>"); + go_error_at(this->location(), "expected %<case%> or %<default%>"); if (!token->is_op(OPERATOR_RCURLY)) this->advance_token(); } @@ -4878,10 +4889,10 @@ Parse::select_stat(Label* label) Location token_loc = token->location(); if (token->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(token_loc, "unexpected semicolon or newline before %<{%>"); + go_error_at(token_loc, "unexpected semicolon or newline before %<{%>"); else { - error_at(this->location(), "expected %<{%>"); + go_error_at(this->location(), "expected %<{%>"); return; } } @@ -4897,7 +4908,7 @@ Parse::select_stat(Label* label) { if (this->peek_token()->is_eof()) { - error_at(this->location(), "expected %<}%>"); + go_error_at(this->location(), "expected %<}%>"); return; } this->comm_clause(select_clauses, &saw_default); @@ -4931,7 +4942,7 @@ Parse::comm_clause(Select_clauses* clauses, bool* saw_default) if (this->peek_token()->is_op(OPERATOR_COLON)) this->advance_token(); else - error_at(this->location(), "expected colon"); + go_error_at(this->location(), "expected colon"); this->gogo_->start_block(this->location()); @@ -4962,7 +4973,7 @@ Parse::comm_clause(Select_clauses* clauses, bool* saw_default) { if (*saw_default) { - error_at(location, "multiple defaults in select"); + go_error_at(location, "multiple defaults in select"); return; } *saw_default = true; @@ -5001,7 +5012,7 @@ Parse::comm_case(bool* is_send, Expression** channel, Expression** val, } else { - error_at(this->location(), "expected %<case%> or %<default%>"); + go_error_at(this->location(), "expected %<case%> or %<default%>"); if (!token->is_op(OPERATOR_RCURLY)) this->advance_token(); return false; @@ -5038,13 +5049,13 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, if (re == NULL) { if (!e->is_error_expression()) - error_at(this->location(), "expected receive expression"); + go_error_at(this->location(), "expected receive expression"); return false; } if (recv_var == "_") { - error_at(recv_var_loc, - "no new variables on left side of %<:=%>"); + go_error_at(recv_var_loc, + "no new variables on left side of %<:=%>"); recv_var = Gogo::erroneous_name(); } *is_send = false; @@ -5073,14 +5084,14 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, if (re == NULL) { if (!e->is_error_expression()) - error_at(this->location(), + go_error_at(this->location(), "expected receive expression"); return false; } if (recv_var == "_" && recv_closed == "_") { - error_at(recv_var_loc, - "no new variables on left side of %<:=%>"); + go_error_at(recv_var_loc, + "no new variables on left side of %<:=%>"); recv_var = Gogo::erroneous_name(); } *is_send = false; @@ -5147,7 +5158,7 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, { if (!this->advance_token()->is_op(OPERATOR_CHANOP)) { - error_at(this->location(), "missing %<<-%>"); + go_error_at(this->location(), "missing %<<-%>"); return false; } *is_send = false; @@ -5172,9 +5183,9 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, if (saw_comma) { if (closed_is_id) - error_at(this->location(), "expected %<=%> or %<:=%>"); + go_error_at(this->location(), "expected %<=%> or %<:=%>"); else - error_at(this->location(), "expected %<=%>"); + go_error_at(this->location(), "expected %<=%>"); return false; } @@ -5188,7 +5199,7 @@ Parse::send_or_recv_stmt(bool* is_send, Expression** channel, Expression** val, return true; } - error_at(this->location(), "expected %<<-%> or %<=%>"); + go_error_at(this->location(), "expected %<<-%> or %<=%>"); return false; } @@ -5215,8 +5226,8 @@ Parse::for_stat(Label* label) { if (token->is_keyword(KEYWORD_VAR)) { - error_at(this->location(), - "var declaration not allowed in for initializer"); + go_error_at(this->location(), + "var declaration not allowed in for initializer"); this->var_decl(); } @@ -5233,17 +5244,18 @@ Parse::for_stat(Label* label) if (cond == NULL && !range_clause.found) { if (saw_send_stmt) - error_at(this->location(), - ("send statement used as value; " - "use select for non-blocking send")); + go_error_at(this->location(), + ("send statement used as value; " + "use select for non-blocking send")); else - error_at(this->location(), "parse error in for statement"); + go_error_at(this->location(), + "parse error in for statement"); } } else { if (range_clause.found) - error_at(this->location(), "parse error after range clause"); + go_error_at(this->location(), "parse error after range clause"); if (cond != NULL) { @@ -5263,7 +5275,7 @@ Parse::for_stat(Label* label) { Location semi_loc = this->location(); if (this->advance_token()->is_op(OPERATOR_LCURLY)) - error_at(semi_loc, "missing %<{%> after for clause"); + go_error_at(semi_loc, "missing %<{%> after for clause"); // Otherwise we will get an error when we call this->block // below. } @@ -5334,7 +5346,7 @@ Parse::for_clause(Expression** cond, Block** post) *cond = NULL; else if (this->peek_token()->is_op(OPERATOR_LCURLY)) { - error_at(this->location(), "missing %<{%> after for clause"); + go_error_at(this->location(), "missing %<{%> after for clause"); *cond = NULL; *post = NULL; return; @@ -5342,7 +5354,7 @@ Parse::for_clause(Expression** cond, Block** post) else *cond = this->expression(PRECEDENCE_NORMAL, false, true, NULL, NULL); if (!this->peek_token()->is_op(OPERATOR_SEMICOLON)) - error_at(this->location(), "expected semicolon"); + go_error_at(this->location(), "expected semicolon"); else this->advance_token(); @@ -5370,7 +5382,7 @@ Parse::range_clause_decl(const Typed_identifier_list* til, p_range_clause->found = true; if (til->size() > 2) - error_at(this->location(), "too many variables for range clause"); + go_error_at(this->location(), "too many variables for range clause"); this->advance_token(); Expression* expr = this->expression(PRECEDENCE_NORMAL, false, false, NULL, @@ -5405,7 +5417,7 @@ Parse::range_clause_decl(const Typed_identifier_list* til, } if (!any_new) - error_at(location, "variables redeclared but no variable is new"); + go_error_at(location, "variables redeclared but no variable is new"); } // The = version of RangeClause. This is called with a list of @@ -5421,7 +5433,7 @@ Parse::range_clause_expr(const Expression_list* vals, go_assert(vals->size() >= 1); if (vals->size() > 2) - error_at(this->location(), "too many variables for range clause"); + go_error_at(this->location(), "too many variables for range clause"); this->advance_token(); p_range_clause->range = this->expression(PRECEDENCE_NORMAL, false, false, @@ -5507,8 +5519,8 @@ Parse::break_stat() { if (this->break_stack_ == NULL || this->break_stack_->empty()) { - error_at(this->location(), - "break statement not within for or switch or select"); + go_error_at(this->location(), + "break statement not within for or switch or select"); return; } enclosing = this->break_stack_->back().first; @@ -5524,8 +5536,8 @@ Parse::break_stat() this->gogo_->add_label_reference(token->identifier(), Linemap::unknown_location(), false); - error_at(token->location(), "invalid break label %qs", - Gogo::message_name(token->identifier()).c_str()); + go_error_at(token->location(), "invalid break label %qs", + Gogo::message_name(token->identifier()).c_str()); this->advance_token(); return; } @@ -5564,7 +5576,7 @@ Parse::continue_stat() { if (this->continue_stack_ == NULL || this->continue_stack_->empty()) { - error_at(this->location(), "continue statement not within for"); + go_error_at(this->location(), "continue statement not within for"); return; } enclosing = this->continue_stack_->back().first; @@ -5580,8 +5592,8 @@ Parse::continue_stat() this->gogo_->add_label_reference(token->identifier(), Linemap::unknown_location(), false); - error_at(token->location(), "invalid continue label %qs", - Gogo::message_name(token->identifier()).c_str()); + go_error_at(token->location(), "invalid continue label %qs", + Gogo::message_name(token->identifier()).c_str()); this->advance_token(); return; } @@ -5609,7 +5621,7 @@ Parse::goto_stat() Location location = this->location(); const Token* token = this->advance_token(); if (!token->is_identifier()) - error_at(this->location(), "expected label for goto"); + go_error_at(this->location(), "expected label for goto"); else { Label* label = this->gogo_->add_label_reference(token->identifier(), @@ -5630,7 +5642,7 @@ Parse::package_clause() std::string name; if (!token->is_keyword(KEYWORD_PACKAGE)) { - error_at(this->location(), "program must start with package clause"); + go_error_at(this->location(), "program must start with package clause"); name = "ERROR"; } else @@ -5641,14 +5653,14 @@ Parse::package_clause() name = token->identifier(); if (name == "_") { - error_at(this->location(), "invalid package name _"); + go_error_at(this->location(), "invalid package name _"); name = Gogo::erroneous_name(); } this->advance_token(); } else { - error_at(this->location(), "package name must be an identifier"); + go_error_at(this->location(), "package name must be an identifier"); name = "ERROR"; } } @@ -5689,7 +5701,7 @@ Parse::import_spec(void*) if (!token->is_string()) { - error_at(this->location(), "import statement not a string"); + go_error_at(this->location(), "import statement not a string"); this->advance_token(); return; } @@ -5712,8 +5724,8 @@ Parse::program() if (token->is_op(OPERATOR_SEMICOLON)) token = this->advance_token(); else - error_at(this->location(), - "expected %<;%> or newline after package clause"); + go_error_at(this->location(), + "expected %<;%> or newline after package clause"); while (token->is_keyword(KEYWORD_IMPORT)) { @@ -5722,8 +5734,8 @@ Parse::program() if (token->is_op(OPERATOR_SEMICOLON)) token = this->advance_token(); else - error_at(this->location(), - "expected %<;%> or newline after import declaration"); + go_error_at(this->location(), + "expected %<;%> or newline after import declaration"); } while (!token->is_eof()) @@ -5732,7 +5744,7 @@ Parse::program() this->declaration(); else { - error_at(this->location(), "expected declaration"); + go_error_at(this->location(), "expected declaration"); this->gogo_->mark_locals_used(); do this->advance_token(); @@ -5749,12 +5761,13 @@ Parse::program() else if (!token->is_eof() || !saw_errors()) { if (token->is_op(OPERATOR_CHANOP)) - error_at(this->location(), - ("send statement used as value; " - "use select for non-blocking send")); + go_error_at(this->location(), + ("send statement used as value; " + "use select for non-blocking send")); else - error_at(this->location(), - "expected %<;%> or newline after top level declaration"); + go_error_at(this->location(), + ("expected %<;%> or newline after top " + "level declaration")); this->skip_past_error(OPERATOR_INVALID); } } @@ -5815,7 +5828,7 @@ Parse::verify_not_sink(Expression* expr) { if (expr->is_sink_expression()) { - error_at(expr->location(), "cannot use _ as value"); + go_error_at(expr->location(), "cannot use _ as value"); expr = Expression::make_error(expr->location()); } |