+2016-09-23 Than McIntosh <thanm@google.com>
+
+ * go-gcc-diagnostics.cc: New file.
+ * go-location.h (Location): Remove operator source_location. Add
+ operator==.
+ * go-system.h: #include <sstream>.
+ * Make-lang.in (GO_OBJS): Add go/go-diagnostics.o and
+ go/go-gcc-diagnostics.o.
+ (CFLAGS-go/go-gcc-diagnostics.o): New variable.
+
2016-09-23 Chris Manghane <cmang@google.com>
PR go/77701
go/export.o \
go/expressions.o \
go/go-backend.o \
+ go/go-diagnostics.o \
go/go-dump.o \
go/go-gcc.o \
+ go/go-gcc-diagnostics.o \
go/go-lang.o \
go/go-linemap.o \
go/go-optimize.o \
CFLAGS-go/go-gcc.o += $(GOINCLUDES)
CFLAGS-go/go-linemap.o += $(GOINCLUDES)
CFLAGS-go/go-sha1.o += $(GOINCLUDES)
+CFLAGS-go/go-gcc-diagnostics.o += $(GOINCLUDES)
go/%.o: go/gofrontend/%.cc
$(COMPILE) $(GOINCLUDES) $<
--- /dev/null
+// go-gcc-diagnostics.cc -- GCC implementation of go diagnostics interface.
+// Copyright (C) 2016 Free Software Foundation, Inc.
+// Contributed by Than McIntosh, Google.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include "go-system.h"
+#include "go-diagnostics.h"
+
+void
+go_be_error_at(const Location location, const std::string& errmsg)
+{
+ source_location gcc_loc = location.gcc_location();
+ error_at(gcc_loc, "%s", errmsg.c_str());
+}
+
+
+void
+go_be_warning_at(const Location location,
+ int opt, const std::string& warningmsg)
+{
+ source_location gcc_loc = location.gcc_location();
+ warning_at(gcc_loc, opt, "%s", warningmsg.c_str());
+}
+
+void
+go_be_fatal_error(const Location location,
+ const std::string& fatalmsg)
+{
+ source_location gcc_loc = location.gcc_location();
+ fatal_error(gcc_loc, "%s", fatalmsg.c_str());
+}
+
+void
+go_be_inform(const Location location,
+ const std::string& infomsg)
+{
+ source_location gcc_loc = location.gcc_location();
+ inform(gcc_loc, "%s", infomsg.c_str());
+}
+
+void
+go_be_get_quotechars(const char** open_qu, const char** close_qu)
+{
+ *open_qu = open_quote;
+ *close_qu = close_quote;
+}
gcc_location() const
{ return this->gcc_loc_; }
- // Temporary hack till error_at and warning_at can deal with a Location.
- operator source_location() const
- { return this->gcc_loc_; }
-
private:
source_location gcc_loc_;
};
return loca.gcc_location() < locb.gcc_location();
}
+inline bool
+operator==(Location loca, Location locb)
+{
+ return loca.gcc_location() == locb.gcc_location();
+}
+
#endif // !defined(GO_LOCATION_H)
#include <map>
#include <set>
#include <vector>
+#include <sstream>
#if defined(HAVE_UNORDERED_MAP)
-4f84c5e0210e674163f3f6462da6f5be9e5b0a36
+57bf3f21005c4508003f65207282c057e3526ec0
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
#include "ast-dump.h"
#include "go-c.h"
#include "go-dump.h"
+#include "go-diagnostics.h"
// The -fgo-dump-ast flag to activate AST dumps.
if (out.fail())
{
- error("cannot open %s:%m, -fgo-dump-ast ignored", dumpname.c_str());
+ go_error_at(Linemap::unknown_location(),
+ "cannot open %s:%m, -fgo-dump-ast ignored", dumpname.c_str());
return;
}
Location location;
Btyped_identifier()
- : name(), btype(NULL), location(UNKNOWN_LOCATION)
+ : name(), btype(NULL), location(Linemap::unknown_location())
{ }
Btyped_identifier(const std::string& a_name, Btype* a_btype,
#include "escape.h"
#include "ast-dump.h"
#include "go-optimize.h"
+#include "go-diagnostics.h"
// class Node.
{
Node::Escape_state* state = (*n)->state(context, NULL);
if (((*n)->encoding() & ESCAPE_MASK) == int(Node::ESCAPE_NONE))
- inform((*n)->location(), "%s %s does not escape",
- strip_packed_prefix(this, debug_function_name(state->fn)).c_str(),
- (*n)->ast_format(this).c_str());
+ go_inform((*n)->location(), "%s %s does not escape",
+ strip_packed_prefix(this, debug_function_name(state->fn)).c_str(),
+ (*n)->ast_format(this).c_str());
}
// TODO(cmang): Which objects in context->noesc actually don't escape.
}
{
Node* n = Node::make_node(s);
std::string fn_name = this->context_->current_function_name();
- inform(s->location(), "[%d] %s esc: %s",
- this->context_->loop_depth(), fn_name.c_str(),
- n->ast_format(gogo).c_str());
+ go_inform(s->location(), "[%d] %s esc: %s",
+ this->context_->loop_depth(), fn_name.c_str(),
+ n->ast_format(gogo).c_str());
}
switch (s->classification())
std::string label_type = (label_stmt->label()->looping()
? "looping"
: "nonlooping");
- inform(s->location(), "%s %s label",
- label_stmt->label()->name().c_str(),
- label_type.c_str());
+ go_inform(s->location(), "%s %s label",
+ label_stmt->label()->name().c_str(),
+ label_type.c_str());
}
}
break;
&& n->is_big(this->context_))
{
if (debug_level > 1)
- inform((*pexpr)->location(), "too large for stack");
+ go_inform((*pexpr)->location(), "too large for stack");
n->set_encoding(Node::ESCAPE_HEAP);
(*pexpr)->address_taken(true);
this->assign(this->context_->sink(), n);
{
Node* n = Node::make_node(*pexpr);
std::string fn_name = this->context_->current_function_name();
- inform((*pexpr)->location(), "[%d] %s esc: %s",
- this->context_->loop_depth(), fn_name.c_str(),
- n->ast_format(gogo).c_str());
+ go_inform((*pexpr)->location(), "[%d] %s esc: %s",
+ this->context_->loop_depth(), fn_name.c_str(),
+ n->ast_format(gogo).c_str());
}
switch ((*pexpr)->classification())
this->assign_deref(this->context_->sink(), appended);
if (debug_level > 2)
- error_at((*pexpr)->location(),
+ go_error_at((*pexpr)->location(),
"special treatment of append(slice1, slice2...)");
// The content of the original slice leaks as well.
++p)
{
if (debug_level > 2)
- inform(call->location(),
- "esccall:: indirect call <- %s, untracked",
- (*p)->ast_format(gogo).c_str());
+ go_inform(call->location(),
+ "esccall:: indirect call <- %s, untracked",
+ (*p)->ast_format(gogo).c_str());
this->assign(this->context_->sink(), *p);
}
&& !fntype->is_tagged())
{
if (debug_level > 2)
- inform(call->location(), "esccall:: %s in recursive group",
- call_node->ast_format(gogo).c_str());
+ go_inform(call->location(), "esccall:: %s in recursive group",
+ call_node->ast_format(gogo).c_str());
Function* f = fn->named_object()->func_value();
const Bindings* callee_bindings = f->block()->bindings();
for (; p != arg_nodes.end(); ++p)
{
if (debug_level > 2)
- inform(call->location(), "esccall:: ... <- %s, untracked",
- (*p)->ast_format(gogo).c_str());
+ go_inform(call->location(), "esccall:: ... <- %s, untracked",
+ (*p)->ast_format(gogo).c_str());
this->assign(this->context_->sink(), *p);
}
}
}
if (debug_level > 2)
- inform(call->location(), "esccall:: %s not recursive",
- call_node->ast_format(gogo).c_str());
+ go_inform(call->location(), "esccall:: %s not recursive",
+ call_node->ast_format(gogo).c_str());
Node::Escape_state* call_state = call_node->state(this->context_, NULL);
if (!call_state->retvals.empty())
- error("esc already decorated call %s", call_node->ast_format(gogo).c_str());
+ go_error_at(Linemap::unknown_location(),
+ "esc already decorated call %s",
+ call_node->ast_format(gogo).c_str());
this->context_->init_retvals(call_node, fntype);
// Receiver.
for (; p != arg_nodes.end(); ++p)
{
if (debug_level > 2)
- inform(call->location(), "esccall:: ... <- %s, untracked",
- (*p)->ast_format(gogo).c_str());
+ go_inform(call->location(), "esccall:: ... <- %s, untracked",
+ (*p)->ast_format(gogo).c_str());
this->assign(this->context_->sink(), *p);
}
}
Gogo* gogo = this->context_->gogo();
int debug_level = gogo->debug_escape_level();
if (debug_level > 1)
- inform(dst->location(), "[%d] %s escassign: %s(%s)[%s] = %s(%s)[%s]",
- this->context_->loop_depth(),
- strip_packed_prefix(gogo, this->context_->current_function_name()).c_str(),
- dst->ast_format(gogo).c_str(), dst->details().c_str(),
- dst->op_format().c_str(),
- src->ast_format(gogo).c_str(), src->details().c_str(),
- src->op_format().c_str());
+ go_inform(dst->location(), "[%d] %s escassign: %s(%s)[%s] = %s(%s)[%s]",
+ this->context_->loop_depth(),
+ strip_packed_prefix(gogo, this->context_->current_function_name()).c_str(),
+ dst->ast_format(gogo).c_str(), dst->details().c_str(),
+ dst->op_format().c_str(),
+ src->ast_format(gogo).c_str(), src->details().c_str(),
+ src->op_format().c_str());
if (dst->expr() != NULL)
{
}
if (this->context_->gogo()->debug_escape_level() > 2)
- inform(src->location(), "assignfromtag:: src= em=%s",
- Escape_note::make_tag(enc).c_str());
+ go_inform(src->location(), "assignfromtag:: src= em=%s",
+ Escape_note::make_tag(enc).c_str());
if (enc == Node::ESCAPE_UNKNOWN)
{
Gogo* gogo = this->context_->gogo();
if (gogo->debug_escape_level() > 2)
- inform(Linemap::unknown_location(), "flows:: %s <- %s",
- dst->ast_format(gogo).c_str(), src->ast_format(gogo).c_str());
+ go_inform(Linemap::unknown_location(), "flows:: %s <- %s",
+ dst->ast_format(gogo).c_str(), src->ast_format(gogo).c_str());
if (dst_state->flows.empty())
this->context_->add_dst(dst);
Gogo* gogo = this->context_->gogo();
int debug_level = gogo->debug_escape_level();
if (debug_level > 1)
- inform(Linemap::unknown_location(),
- "escwalk: level:{%d %d} depth:%d "
- "op=%s %s(%s) "
- "scope:%s[%d] "
- "extraloopdepth=%d",
- level.value(), level.suffix_value(), this->context_->pdepth(),
- src->op_format().c_str(),
- src->ast_format(gogo).c_str(),
- src->details().c_str(),
- debug_function_name(src_state->fn).c_str(),
- src_state->loop_depth,
- extra_loop_depth);
+ go_inform(Linemap::unknown_location(),
+ "escwalk: level:{%d %d} depth:%d "
+ "op=%s %s(%s) "
+ "scope:%s[%d] "
+ "extraloopdepth=%d",
+ level.value(), level.suffix_value(), this->context_->pdepth(),
+ src->op_format().c_str(),
+ src->ast_format(gogo).c_str(),
+ src->details().c_str(),
+ debug_function_name(src_state->fn).c_str(),
+ src_state->loop_depth,
+ extra_loop_depth);
this->context_->increase_pdepth();
if (debug_level != 0)
{
if (debug_level == 1)
- inform(src->location(),
- "leaking param: %s to result %s level=%d",
- src->ast_format(gogo).c_str(), dst->ast_format(gogo).c_str(),
- level.value());
+ go_inform(src->location(),
+ "leaking param: %s to result %s level=%d",
+ src->ast_format(gogo).c_str(),
+ dst->ast_format(gogo).c_str(),
+ level.value());
else
- inform(src->location(),
- "leaking param: %s to result %s level={%d %d}",
- src->ast_format(gogo).c_str(), dst->ast_format(gogo).c_str(),
- level.value(), level.suffix_value());
+ go_inform(src->location(),
+ "leaking param: %s to result %s level={%d %d}",
+ src->ast_format(gogo).c_str(),
+ dst->ast_format(gogo).c_str(),
+ level.value(), level.suffix_value());
}
if ((src->encoding() & ESCAPE_MASK) != Node::ESCAPE_RETURN)
Node::ESCAPE_NONE);
src->set_encoding(enc);
if (debug_level != 0)
- inform(src->location(), "mark escaped content: %s",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "mark escaped content: %s",
+ src->ast_format(gogo).c_str());
}
// A src object leaks if its value or address is assigned to a dst object
Node::ESCAPE_NONE);
src->set_encoding(enc);
if (debug_level != 0)
- inform(src->location(), "leaking param content: %s",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "leaking param content: %s",
+ src->ast_format(gogo).c_str());
}
else
{
if (debug_level != 0)
- inform(src->location(), "leaking param");
+ go_inform(src->location(), "leaking param");
src->set_encoding(Node::ESCAPE_SCOPE);
}
}
if (e->enclosed_var_expression() != NULL)
{
if (src_leaks && debug_level != 0)
- inform(src->location(), "leaking closure reference %s",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "leaking closure reference %s",
+ src->ast_format(gogo).c_str());
Node* enclosed_node =
Node::make_node(e->enclosed_var_expression()->variable());
src->set_encoding(Node::ESCAPE_HEAP);
if (debug_level != 0)
{
- inform(underlying->location(), "moved to heap: %s",
- underlying_node->ast_format(gogo).c_str());
+ go_inform(underlying->location(), "moved to heap: %s",
+ underlying_node->ast_format(gogo).c_str());
if (debug_level > 1)
- inform(src->location(),
- "%s escapes to heap, level={%d %d}, "
- "dst.eld=%d, src.eld=%d",
- src->ast_format(gogo).c_str(), level.value(),
- level.suffix_value(), dst_state->loop_depth,
- mod_loop_depth);
+ go_inform(src->location(),
+ "%s escapes to heap, level={%d %d}, "
+ "dst.eld=%d, src.eld=%d",
+ src->ast_format(gogo).c_str(), level.value(),
+ level.suffix_value(), dst_state->loop_depth,
+ mod_loop_depth);
else
- inform(src->location(), "%s escapes to heap",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "%s escapes to heap",
+ src->ast_format(gogo).c_str());
}
this->flood(level.decrease(), dst,
{
src->set_encoding(Node::ESCAPE_HEAP);
if (debug_level != 0)
- inform(src->location(), "%s escapes to heap",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "%s escapes to heap",
+ src->ast_format(gogo).c_str());
extra_loop_depth = mod_loop_depth;
}
}
{
src->set_encoding(Node::ESCAPE_HEAP);
if (debug_level != 0)
- inform(src->location(), "%s escapes to heap",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "%s escapes to heap",
+ src->ast_format(gogo).c_str());
extra_loop_depth = mod_loop_depth;
}
break;
// so if this leaks, this call must be done on the heap.
src->set_encoding(Node::ESCAPE_HEAP);
if (debug_level != 0)
- inform(src->location(), "%s escapes to heap",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "%s escapes to heap",
+ src->ast_format(gogo).c_str());
}
}
}
// Calls to Runtime::NEW get lowered into an allocation expression.
src->set_encoding(Node::ESCAPE_HEAP);
if (debug_level != 0)
- inform(src->location(), "%s escapes to heap",
- src->ast_format(gogo).c_str());
+ go_inform(src->location(), "%s escapes to heap",
+ src->ast_format(gogo).c_str());
}
else if ((e->field_reference_expression() != NULL
&& e->field_reference_expression()->expr()->unary_expression() == NULL)
Node::Escape_state* state = dst->state(context, NULL);
Gogo* gogo = context->gogo();
if (gogo->debug_escape_level() > 1)
- inform(Linemap::unknown_location(), "escflood:%d: dst %s scope:%s[%d]",
- context->flood_id(), dst->ast_format(gogo).c_str(),
- debug_function_name(state->fn).c_str(),
- state->loop_depth);
+ go_inform(Linemap::unknown_location(), "escflood:%d: dst %s scope:%s[%d]",
+ context->flood_id(), dst->ast_format(gogo).c_str(),
+ debug_function_name(state->fn).c_str(),
+ state->loop_depth);
Escape_analysis_flood eaf(context);
for (std::set<Node*>::const_iterator p = state->flows.begin();
#include "go-c.h"
#include "gogo.h"
+#include "go-diagnostics.h"
#include "types.h"
#include "export.h"
#include "import.h"
void
Expression::report_error(const char* msg)
{
- error_at(this->location_, "%s", msg);
+ go_error_at(this->location_, "%s", msg);
this->set_is_error();
}
// can't take their address.
if (fntype->is_builtin())
{
- error_at(loc,
- "invalid use of special builtin function %qs; must be called",
- no->message_name().c_str());
+ go_error_at(loc,
+ "invalid use of special builtin function %qs; must be called",
+ no->message_name().c_str());
return gogo->backend()->error_expression();
}
{
if (no->func_declaration_value()->type()->is_builtin())
{
- error_at(this->location(),
- ("invalid use of special builtin function %qs; "
- "must be called"),
- no->message_name().c_str());
+ go_error_at(this->location(),
+ ("invalid use of special builtin function %qs; "
+ "must be called"),
+ no->message_name().c_str());
return gogo->backend()->error_expression();
}
descriptor = no->func_declaration_value()->descriptor(gogo, no);
if (this->is_composite_literal_key_)
return this;
if (!this->no_error_message_)
- error_at(location, "reference to undefined name %qs",
- this->named_object_->message_name().c_str());
+ go_error_at(location, "reference to undefined name %qs",
+ this->named_object_->message_name().c_str());
return Expression::make_error(location);
}
}
if (this->is_composite_literal_key_)
return this;
if (!this->no_error_message_)
- error_at(location, "reference to undefined type %qs",
- real->message_name().c_str());
+ go_error_at(location, "reference to undefined type %qs",
+ real->message_name().c_str());
return Expression::make_error(location);
case Named_object::NAMED_OBJECT_VAR:
real->var_value()->set_is_used();
if (this->is_composite_literal_key_)
return this;
if (!this->no_error_message_)
- error_at(location, "unexpected reference to package");
+ go_error_at(location, "unexpected reference to package");
return Expression::make_error(location);
default:
go_unreachable();
}
else
{
- error_at(imp->location(), "bad string constant");
+ go_error_at(imp->location(), "bad string constant");
return Expression::make_error(imp->location());
}
}
else
{
if (!saw_errors())
- error_at(this->location(),
- "unknown type for large integer constant");
+ go_error_at(this->location(),
+ "unknown type for large integer constant");
return context->gogo()->backend()->error_expression();
}
}
pos = plus_pos;
else
{
- error_at(imp->location(), "bad number in import data: %qs",
- num.c_str());
+ go_error_at(imp->location(), "bad number in import data: %qs",
+ num.c_str());
return Expression::make_error(imp->location());
}
if (pos == std::string::npos)
std::string real_str = num.substr(0, pos);
if (mpfr_init_set_str(real, real_str.c_str(), 10, GMP_RNDN) != 0)
{
- error_at(imp->location(), "bad number in import data: %qs",
- real_str.c_str());
+ go_error_at(imp->location(), "bad number in import data: %qs",
+ real_str.c_str());
return Expression::make_error(imp->location());
}
}
mpfr_t imag;
if (mpfr_init_set_str(imag, imag_str.c_str(), 10, GMP_RNDN) != 0)
{
- error_at(imp->location(), "bad number in import data: %qs",
- imag_str.c_str());
+ go_error_at(imp->location(), "bad number in import data: %qs",
+ imag_str.c_str());
return Expression::make_error(imp->location());
}
mpc_t cval;
mpz_t val;
if (mpz_init_set_str(val, num.c_str(), 10) != 0)
{
- error_at(imp->location(), "bad number in import data: %qs",
- num.c_str());
+ go_error_at(imp->location(), "bad number in import data: %qs",
+ num.c_str());
return Expression::make_error(imp->location());
}
Expression* ret;
mpfr_t val;
if (mpfr_init_set_str(val, num.c_str(), 10, GMP_RNDN) != 0)
{
- error_at(imp->location(), "bad number in import data: %qs",
- num.c_str());
+ go_error_at(imp->location(), "bad number in import data: %qs",
+ num.c_str());
return Expression::make_error(imp->location());
}
Expression* ret = Expression::make_float(&val, NULL, imp->location());
{
if (iota_value == -1)
{
- error_at(this->location(),
- "iota is only defined in const declarations");
+ go_error_at(this->location(),
+ "iota is only defined in const declarations");
iota_value = 0;
}
return Expression::make_integer_ul(iota_value, NULL, this->location());
int adv = Lex::fetch_char(p, &c);
if (adv == 0)
{
- warning_at(this->location(), 0,
+ go_warning_at(this->location(), 0,
"invalid UTF-8 encoding");
adv = 1;
}
if (Type::are_convertible(type, expr_type, &reason))
return;
- error_at(this->location(), "%s", reason.c_str());
+ go_error_at(this->location(), "%s", reason.c_str());
this->set_is_error();
}
// *&x == x.
if (!ue->expr_->is_addressable() && !ue->create_temp_)
{
- error_at(ue->location(),
- "invalid operand for unary %<&%>");
+ go_error_at(ue->location(),
+ "invalid operand for unary %<&%>");
this->set_is_error();
}
return ue->expr_;
// having to deal with TYPE_VOID in other places.
if (op == OPERATOR_MULT && expr->type()->is_unsafe_pointer_type())
{
- error_at(this->location(), "invalid indirect of %<unsafe.Pointer%>");
+ go_error_at(this->location(), "invalid indirect of %<unsafe.Pointer%>");
return Expression::make_error(this->location());
}
{
if (!this->create_temp_)
{
- error_at(this->location(), "invalid operand for unary %<&%>");
+ go_error_at(this->location(), "invalid operand for unary %<&%>");
this->set_is_error();
}
}
mpz_add(val, left_val, right_val);
if (mpz_sizeinbase(val, 2) > 0x100000)
{
- error_at(location, "constant addition overflow");
+ go_error_at(location, "constant addition overflow");
nc->set_invalid();
mpz_set_ui(val, 1);
}
mpz_sub(val, left_val, right_val);
if (mpz_sizeinbase(val, 2) > 0x100000)
{
- error_at(location, "constant subtraction overflow");
+ go_error_at(location, "constant subtraction overflow");
nc->set_invalid();
mpz_set_ui(val, 1);
}
mpz_mul(val, left_val, right_val);
if (mpz_sizeinbase(val, 2) > 0x100000)
{
- error_at(location, "constant multiplication overflow");
+ go_error_at(location, "constant multiplication overflow");
nc->set_invalid();
mpz_set_ui(val, 1);
}
mpz_tdiv_q(val, left_val, right_val);
else
{
- error_at(location, "division by zero");
+ go_error_at(location, "division by zero");
nc->set_invalid();
mpz_set_ui(val, 0);
}
mpz_tdiv_r(val, left_val, right_val);
else
{
- error_at(location, "division by zero");
+ go_error_at(location, "division by zero");
nc->set_invalid();
mpz_set_ui(val, 0);
}
mpz_mul_2exp(val, left_val, shift);
else
{
- error_at(location, "shift count overflow");
+ go_error_at(location, "shift count overflow");
nc->set_invalid();
mpz_set_ui(val, 1);
}
unsigned long shift = mpz_get_ui(right_val);
if (mpz_cmp_ui(right_val, shift) != 0)
{
- error_at(location, "shift count overflow");
+ go_error_at(location, "shift count overflow");
nc->set_invalid();
mpz_set_ui(val, 1);
}
mpfr_div(val, left_val, right_val, GMP_RNDN);
else
{
- error_at(location, "division by zero");
+ go_error_at(location, "division by zero");
nc->set_invalid();
mpfr_set_ui(val, 0, GMP_RNDN);
}
case OPERATOR_DIV:
if (mpc_cmp_si(right_val, 0) == 0)
{
- error_at(location, "division by zero");
+ go_error_at(location, "division by zero");
nc->set_invalid();
mpc_set_ui(val, 0, MPC_RNDNN);
break;
if (!type->is_boolean_type()
|| !otype->is_boolean_type())
{
- error_at(location, "expected boolean type");
+ go_error_at(location, "expected boolean type");
return false;
}
break;
std::string reason;
if (!Type::are_compatible_for_comparison(true, type, otype, &reason))
{
- error_at(location, "%s", reason.c_str());
+ go_error_at(location, "%s", reason.c_str());
return false;
}
}
std::string reason;
if (!Type::are_compatible_for_comparison(false, type, otype, &reason))
{
- error_at(location, "%s", reason.c_str());
+ go_error_at(location, "%s", reason.c_str());
return false;
}
}
if ((!type->is_numeric_type() && !type->is_string_type())
|| (!otype->is_numeric_type() && !otype->is_string_type()))
{
- error_at(location,
+ go_error_at(location,
"expected integer, floating, complex, or string type");
return false;
}
case OPERATOR_DIVEQ:
if (!type->is_numeric_type() || !otype->is_numeric_type())
{
- error_at(location, "expected integer, floating, or complex type");
+ go_error_at(location, "expected integer, floating, or complex type");
return false;
}
break;
case OPERATOR_BITCLEAREQ:
if (type->integer_type() == NULL || otype->integer_type() == NULL)
{
- error_at(location, "expected integer type");
+ go_error_at(location, "expected integer type");
return false;
}
break;
}
else
{
- error_at(imp->location(), "unrecognized binary operator");
+ go_error_at(imp->location(), "unrecognized binary operator");
return Expression::make_error(imp->location());
}
Expression* arg = args->front();
if (!arg->is_type_expression())
{
- error_at(arg->location(), "expected type");
+ go_error_at(arg->location(), "expected type");
this->set_is_error();
}
else
if (!slice_type->is_slice_type())
{
if (slice_type->is_nil_type())
- error_at(args->front()->location(), "use of untyped nil");
+ go_error_at(args->front()->location(), "use of untyped nil");
else
- error_at(args->front()->location(),
- "argument 1 must be a slice");
+ go_error_at(args->front()->location(),
+ "argument 1 must be a slice");
this->set_is_error();
return this;
}
Expression* first_arg = *parg;
if (!first_arg->is_type_expression())
{
- error_at(first_arg->location(), "expected type");
+ go_error_at(first_arg->location(), "expected type");
this->set_is_error();
return Expression::make_error(this->location());
}
case Numeric_constant::NC_UL_VALID:
break;
case Numeric_constant::NC_UL_NOTINT:
- error_at(e->location(), "non-integer %s argument to make",
- is_length ? "len" : "cap");
+ go_error_at(e->location(), "non-integer %s argument to make",
+ is_length ? "len" : "cap");
return false;
case Numeric_constant::NC_UL_NEGATIVE:
- error_at(e->location(), "negative %s argument to make",
- is_length ? "len" : "cap");
+ go_error_at(e->location(), "negative %s argument to make",
+ is_length ? "len" : "cap");
return false;
case Numeric_constant::NC_UL_BIG:
// We don't want to give a compile-time error for a 64-bit
Type* int_type = Type::lookup_integer_type("int");
if (bits >= int_type->integer_type()->bits())
{
- error_at(e->location(), "%s argument too large for make",
- is_length ? "len" : "cap");
+ go_error_at(e->location(), "%s argument too large for make",
+ is_length ? "len" : "cap");
return false;
}
if (e->type()->integer_type() != NULL)
return true;
- error_at(e->location(), "non-integer %s argument to make",
- is_length ? "len" : "cap");
+ go_error_at(e->location(), "non-integer %s argument to make",
+ is_length ? "len" : "cap");
return false;
}
if (args == NULL)
{
if (this->code_ == BUILTIN_PRINT)
- warning_at(this->location(), 0,
+ go_warning_at(this->location(), 0,
"no arguments for builtin function %<%s%>",
(this->code_ == BUILTIN_PRINT
? "print"
this->report_error(_("argument 2 has invalid type"));
else
{
- error_at(this->location(), "argument 2 has invalid type (%s)",
- reason.c_str());
+ go_error_at(this->location(),
+ "argument 2 has invalid type (%s)",
+ reason.c_str());
this->set_is_error();
}
}
Numeric_constant nc;
if (!this->numeric_constant_value(&nc))
{
- error_at(this->location(), "value is not constant");
+ go_error_at(this->location(), "value is not constant");
return;
}
// the ellipsis operator should be applied to. If we unpack the
// the call into its individual results here, the ellipsis will be
// applied to the last result.
- error_at(call->location(),
- _("multiple-value argument in single-value context"));
+ go_error_at(call->location(),
+ _("multiple-value argument in single-value context"));
return Expression::make_error(call->location());
}
this->report_error(_("too many arguments"));
else
{
- error_at(this->location(),
- _("invalid use of %<...%> with non-slice"));
+ go_error_at(this->location(),
+ _("invalid use of %<...%> with non-slice"));
this->set_is_error();
}
return;
if (!issued_error)
{
if (reason.empty())
- error_at(argument_location, "argument %d has incompatible type", i);
+ go_error_at(argument_location, "argument %d has incompatible type", i);
else
- error_at(argument_location,
- "argument %d has incompatible type (%s)",
- i, reason.c_str());
+ go_error_at(argument_location,
+ "argument %d has incompatible type (%s)",
+ i, reason.c_str());
}
this->set_is_error();
return false;
this->report_error(_("incompatible type for receiver"));
else
{
- error_at(this->location(),
- "incompatible type for receiver (%s)",
- reason.c_str());
+ go_error_at(this->location(),
+ "incompatible type for receiver (%s)",
+ reason.c_str());
this->set_is_error();
}
}
{
if (!fntype->is_varargs())
{
- error_at(this->location(),
- _("invalid use of %<...%> calling non-variadic function"));
+ go_error_at(this->location(),
+ _("invalid use of %<...%> calling non-variadic function"));
this->set_is_error();
return;
}
}
else if (left->is_type_expression())
{
- error_at(location, "attempt to index type expression");
+ go_error_at(location, "attempt to index type expression");
return Expression::make_error(location);
}
else if (type->array_type() != NULL)
{
if (cap != NULL)
{
- error_at(location, "invalid 3-index slice of string");
+ go_error_at(location, "invalid 3-index slice of string");
return Expression::make_error(location);
}
return Expression::make_string_index(left, start, end, location);
{
if (end != NULL || cap != NULL)
{
- error_at(location, "invalid slice of map");
+ go_error_at(location, "invalid slice of map");
return Expression::make_error(location);
}
return Expression::make_map_index(left, start, location);
}
else
{
- error_at(location,
- "attempt to index object which is not array, string, or map");
+ go_error_at(location,
+ "attempt to index object which is not array, string, or map");
return Expression::make_error(location);
}
}
? mpz_cmp(ival, lval) >= 0
: mpz_cmp(ival, lval) > 0)))
{
- error_at(this->start_->location(), "array index out of bounds");
+ go_error_at(this->start_->location(), "array index out of bounds");
this->set_is_error();
}
}
|| mpz_sizeinbase(eval, 2) >= int_bits
|| (lval_valid && mpz_cmp(eval, lval) > 0))
{
- error_at(this->end_->location(), "array index out of bounds");
+ go_error_at(this->end_->location(), "array index out of bounds");
this->set_is_error();
}
else if (ival_valid && mpz_cmp(ival, eval) > 0)
|| mpz_sizeinbase(cval, 2) >= int_bits
|| (lval_valid && mpz_cmp(cval, lval) > 0))
{
- error_at(this->cap_->location(), "array index out of bounds");
+ go_error_at(this->cap_->location(), "array index out of bounds");
this->set_is_error();
}
else if (ival_valid && mpz_cmp(ival, cval) > 0)
{
- error_at(this->cap_->location(),
- "invalid slice index: capacity less than start");
+ go_error_at(this->cap_->location(),
+ "invalid slice index: capacity less than start");
this->set_is_error();
}
else if (eval_valid && mpz_cmp(eval, cval) > 0)
{
- error_at(this->cap_->location(),
- "invalid slice index: capacity less than length");
+ go_error_at(this->cap_->location(),
+ "invalid slice index: capacity less than length");
this->set_is_error();
}
mpz_clear(cval);
? mpz_cmp_ui(ival, sval.length()) >= 0
: mpz_cmp_ui(ival, sval.length()) > 0)))
{
- error_at(this->start_->location(), "string index out of bounds");
+ go_error_at(this->start_->location(), "string index out of bounds");
this->set_is_error();
}
}
if (mpz_sgn(eval) < 0
|| (sval_valid && mpz_cmp_ui(eval, sval.length()) > 0))
{
- error_at(this->end_->location(), "string index out of bounds");
+ go_error_at(this->end_->location(), "string index out of bounds");
this->set_is_error();
}
else if (ival_valid && mpz_cmp(ival, eval) > 0)
this->report_error(_("incompatible type for map index"));
else
{
- error_at(this->location(), "incompatible type for map index (%s)",
- reason.c_str());
+ go_error_at(this->location(), "incompatible type for map index (%s)",
+ reason.c_str());
this->set_is_error();
}
}
interface_type->find_method(this->name_);
if (method == NULL)
{
- error_at(this->location(), "method %qs not in interface",
- Gogo::message_name(this->name_).c_str());
+ go_error_at(this->location(), "method %qs not in interface",
+ Gogo::message_name(this->name_).c_str());
this->set_is_error();
}
}
Named_type* nt = type->named_type();
if (nt == NULL)
{
- error_at(location,
- ("method expression requires named type or "
- "pointer to named type"));
+ go_error_at(location,
+ ("method expression requires named type or "
+ "pointer to named type"));
return Expression::make_error(location);
}
|| (left_type->named_type() != NULL && left_type->points_to() != NULL))
{
if (!is_ambiguous)
- error_at(location, "type %<%s%s%> has no method %<%s%>",
- is_pointer ? "*" : "",
- nt->message_name().c_str(),
- Gogo::message_name(name).c_str());
+ go_error_at(location, "type %<%s%s%> has no method %<%s%>",
+ is_pointer ? "*" : "",
+ nt->message_name().c_str(),
+ Gogo::message_name(name).c_str());
else
- error_at(location, "method %<%s%s%> is ambiguous in type %<%s%>",
- Gogo::message_name(name).c_str(),
- is_pointer ? "*" : "",
- nt->message_name().c_str());
+ go_error_at(location, "method %<%s%s%> is ambiguous in type %<%s%>",
+ Gogo::message_name(name).c_str(),
+ is_pointer ? "*" : "",
+ nt->message_name().c_str());
return Expression::make_error(location);
}
if (method != NULL && !is_pointer && !method->is_value_method())
{
- error_at(location, "method requires pointer (use %<(*%s).%s%>)",
- nt->message_name().c_str(),
- Gogo::message_name(name).c_str());
+ go_error_at(location, "method requires pointer (use %<(*%s).%s%>)",
+ nt->message_name().c_str(),
+ Gogo::message_name(name).c_str());
return Expression::make_error(location);
}
if (!Type::are_assignable(pf->type(), (*pv)->type(), &reason))
{
if (reason.empty())
- error_at((*pv)->location(),
- "incompatible type for field %d in struct construction",
- i + 1);
+ go_error_at((*pv)->location(),
+ "incompatible type for field %d in struct construction",
+ i + 1);
else
- error_at((*pv)->location(),
- ("incompatible type for field %d in "
- "struct construction (%s)"),
- i + 1, reason.c_str());
+ go_error_at((*pv)->location(),
+ ("incompatible type for field %d in "
+ "struct construction (%s)"),
+ i + 1, reason.c_str());
this->set_is_error();
}
}
if (*pv != NULL
&& !Type::are_assignable(element_type, (*pv)->type(), NULL))
{
- error_at((*pv)->location(),
- "incompatible type for element %d in composite literal",
- i + 1);
+ go_error_at((*pv)->location(),
+ "incompatible type for element %d in composite literal",
+ i + 1);
this->set_is_error();
}
}
{
if (!Type::are_assignable(key_type, (*pv)->type(), NULL))
{
- error_at((*pv)->location(),
- "incompatible type for element %d key in map construction",
- i + 1);
+ go_error_at((*pv)->location(),
+ "incompatible type for element %d key in map construction",
+ i + 1);
this->set_is_error();
}
++pv;
if (!Type::are_assignable(val_type, (*pv)->type(), NULL))
{
- error_at((*pv)->location(),
- ("incompatible type for element %d value "
- "in map construction"),
+ go_error_at((*pv)->location(),
+ ("incompatible type for element %d value "
+ "in map construction"),
i + 1);
this->set_is_error();
}
else
{
if (!type->is_error())
- error_at(this->location(),
- ("may only omit types within composite literals "
- "of slice, array, or map type"));
+ go_error_at(this->location(),
+ ("may only omit types within composite literals "
+ "of slice, array, or map type"));
return Expression::make_error(this->location());
}
}
ret = this->lower_map(gogo, function, inserter, type);
else
{
- error_at(this->location(),
- ("expected struct, slice, array, or map type "
- "for composite literal"));
+ go_error_at(this->location(),
+ ("expected struct, slice, array, or map type "
+ "for composite literal"));
return Expression::make_error(this->location());
}
{
if (Gogo::is_hidden_name(pf->field_name())
|| pf->is_embedded_builtin(gogo))
- error_at(this->location(),
- "assignment of unexported field %qs in %qs literal",
- Gogo::message_name(pf->field_name()).c_str(),
- type->named_type()->message_name().c_str());
+ go_error_at(this->location(),
+ "assignment of unexported field %qs in %qs literal",
+ Gogo::message_name(pf->field_name()).c_str(),
+ type->named_type()->message_name().c_str());
}
}
if (name_expr == NULL)
{
- error_at(val->location(), "mixture of field and value initializers");
+ go_error_at(val->location(),
+ "mixture of field and value initializers");
return Expression::make_error(location);
}
}
if (bad_key)
{
- error_at(name_expr->location(), "expected struct field name");
+ go_error_at(name_expr->location(), "expected struct field name");
return Expression::make_error(location);
}
const Struct_field* sf = st->find_local_field(name, &index);
if (sf == NULL)
{
- error_at(name_expr->location(), "unknown field %qs in %qs",
- Gogo::message_name(name).c_str(),
- (type->named_type() != NULL
- ? type->named_type()->message_name().c_str()
- : "unnamed struct"));
+ go_error_at(name_expr->location(), "unknown field %qs in %qs",
+ Gogo::message_name(name).c_str(),
+ (type->named_type() != NULL
+ ? type->named_type()->message_name().c_str()
+ : "unnamed struct"));
return Expression::make_error(location);
}
if (vals[index] != NULL)
{
- error_at(name_expr->location(),
- "duplicate value for field %qs in %qs",
- Gogo::message_name(name).c_str(),
- (type->named_type() != NULL
- ? type->named_type()->message_name().c_str()
- : "unnamed struct"));
+ go_error_at(name_expr->location(),
+ "duplicate value for field %qs in %qs",
+ Gogo::message_name(name).c_str(),
+ (type->named_type() != NULL
+ ? type->named_type()->message_name().c_str()
+ : "unnamed struct"));
return Expression::make_error(location);
}
&& type->named_type()->named_object()->package() != NULL
&& (Gogo::is_hidden_name(sf->field_name())
|| sf->is_embedded_builtin(gogo)))
- error_at(name_expr->location(),
- "assignment of unexported field %qs in %qs literal",
- Gogo::message_name(sf->field_name()).c_str(),
- type->named_type()->message_name().c_str());
+ go_error_at(name_expr->location(),
+ "assignment of unexported field %qs in %qs literal",
+ Gogo::message_name(sf->field_name()).c_str(),
+ type->named_type()->message_name().c_str());
vals[index] = val;
traverse_order->push_back(index);
{
// This is a weird case like bug462 in the testsuite.
if (external_expr == NULL)
- error_at(this->location(), "unknown field in %qs literal",
- (type->named_type() != NULL
- ? type->named_type()->message_name().c_str()
- : "unnamed struct"));
+ go_error_at(this->location(), "unknown field in %qs literal",
+ (type->named_type() != NULL
+ ? type->named_type()->message_name().c_str()
+ : "unnamed struct"));
else
- error_at(external_expr->location(), "unknown field %qs in %qs",
- external_no->message_name().c_str(),
- (type->named_type() != NULL
- ? type->named_type()->message_name().c_str()
- : "unnamed struct"));
+ go_error_at(external_expr->location(), "unknown field %qs in %qs",
+ external_no->message_name().c_str(),
+ (type->named_type() != NULL
+ ? type->named_type()->message_name().c_str()
+ : "unnamed struct"));
return Expression::make_error(location);
}
Numeric_constant nc;
if (!index_expr->numeric_constant_value(&nc))
{
- error_at(index_expr->location(),
- "index expression is not integer constant");
+ go_error_at(index_expr->location(),
+ "index expression is not integer constant");
return Expression::make_error(location);
}
case Numeric_constant::NC_UL_VALID:
break;
case Numeric_constant::NC_UL_NOTINT:
- error_at(index_expr->location(),
- "index expression is not integer constant");
+ go_error_at(index_expr->location(),
+ "index expression is not integer constant");
return Expression::make_error(location);
case Numeric_constant::NC_UL_NEGATIVE:
- error_at(index_expr->location(), "index expression is negative");
+ go_error_at(index_expr->location(),
+ "index expression is negative");
return Expression::make_error(location);
case Numeric_constant::NC_UL_BIG:
- error_at(index_expr->location(), "index value overflow");
+ go_error_at(index_expr->location(), "index value overflow");
return Expression::make_error(location);
default:
go_unreachable();
if (sizeof(index) <= static_cast<size_t>(inttype->bits() * 8)
&& index >> (inttype->bits() - 1) != 0)
{
- error_at(index_expr->location(), "index value overflow");
+ go_error_at(index_expr->location(), "index value overflow");
return Expression::make_error(location);
}
if (std::find(indexes->begin(), indexes->end(), index)
!= indexes->end())
{
- error_at(index_expr->location(), "duplicate value for index %lu",
- index);
+ go_error_at(index_expr->location(),
+ "duplicate value for index %lu",
+ index);
return Expression::make_error(location);
}
if (sizeof(size) <= static_cast<size_t>(it->bits() * 8)
&& size >> (it->bits() - 1) != 0)
{
- error_at(location, "too many elements in composite literal");
+ go_error_at(location, "too many elements in composite literal");
return Expression::make_error(location);
}
}
{
if (this->vals_->size() > val)
{
- error_at(location, "too many elements in composite literal");
+ go_error_at(location,
+ "too many elements in composite literal");
return Expression::make_error(location);
}
}
unsigned long max = indexes->back();
if (max >= val)
{
- error_at(location,
- ("some element keys in composite literal "
- "are out of range"));
+ go_error_at(location,
+ ("some element keys in composite literal "
+ "are out of range"));
return Expression::make_error(location);
}
}
{
if (!this->has_keys_)
{
- error_at(location, "map composite literal must have keys");
+ go_error_at(location, "map composite literal must have keys");
return Expression::make_error(location);
}
if (*p == NULL)
{
++p;
- error_at((*p)->location(),
- "map composite literal must have keys for every value");
+ go_error_at((*p)->location(),
+ ("map composite literal must "
+ "have keys for every value"));
return Expression::make_error(location);
}
// Make sure we have lowered the key; it may not have been
this->report_error(_("impossible type assertion: "
"type does not implement interface"));
else
- error_at(this->location(),
- ("impossible type assertion: "
- "type does not implement interface (%s)"),
- reason.c_str());
+ go_error_at(this->location(),
+ ("impossible type assertion: "
+ "type does not implement interface (%s)"),
+ reason.c_str());
}
this->set_is_error();
}
return Type_conversion_expression::do_import(imp);
else
{
- error_at(imp->location(), "import error: expected expression");
+ go_error_at(imp->location(), "import error: expected expression");
return Expression::make_error(imp->location());
}
}
{
if (issue_error)
{
- error_at(location,
- "floating point constant truncated to integer");
+ go_error_at(location,
+ "floating point constant truncated to integer");
this->set_invalid();
}
return false;
{
if (issue_error)
{
- error_at(location, "complex constant truncated to integer");
+ go_error_at(location, "complex constant truncated to integer");
this->set_invalid();
}
return false;
if (!ret && issue_error)
{
- error_at(location, "integer constant overflow");
+ go_error_at(location, "integer constant overflow");
this->set_invalid();
}
if (issue_error)
{
this->set_invalid();
- error_at(location, "complex constant truncated to float");
+ go_error_at(location, "complex constant truncated to float");
}
return false;
}
if (!ret && issue_error)
{
- error_at(location, "floating point constant overflow");
+ go_error_at(location, "floating point constant overflow");
this->set_invalid();
}
{
if (issue_error)
{
- error_at(location, "complex real part overflow");
+ go_error_at(location, "complex real part overflow");
this->set_invalid();
}
ret = false;
{
if (issue_error)
{
- error_at(location, "complex imaginary part overflow");
+ go_error_at(location, "complex imaginary part overflow");
this->set_invalid();
}
ret = false;
--- /dev/null
+// go-diagnostics.cc -- Go error/warning diagnostics utilities.
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "go-diagnostics.h"
+
+static std::string
+mformat_value()
+{
+ return std::string(xstrerror(errno));
+}
+
+// Rewrite a format string to expand any extensions not
+// supported by sprintf(). See comments in go-diagnostics.h
+// for list of supported format specifiers.
+
+static std::string
+expand_format(const char* fmt)
+{
+ std::stringstream ss;
+ for (const char* c = fmt; *c; ++c)
+ {
+ if (*c != '%')
+ {
+ ss << *c;
+ continue;
+ }
+ c++;
+ switch (*c)
+ {
+ case '\0':
+ {
+ // malformed format string
+ go_unreachable();
+ }
+ case '%':
+ {
+ ss << "%";
+ break;
+ }
+ case 'm':
+ {
+ ss << mformat_value();
+ break;
+ }
+ case '<':
+ {
+ ss << go_open_quote();
+ break;
+ }
+ case '>':
+ {
+ ss << go_close_quote();
+ break;
+ }
+ case 'q':
+ {
+ ss << go_open_quote();
+ c++;
+ if (*c == 'm')
+ {
+ ss << mformat_value();
+ }
+ else
+ {
+ ss << "%" << *c;
+ }
+ ss << go_close_quote();
+ break;
+ }
+ default:
+ {
+ ss << "%" << *c;
+ }
+ }
+ }
+ return ss.str();
+}
+
+// Expand message format specifiers, using a combination of
+// expand_format above to handle extensions (ex: %m, %q) and vasprintf()
+// to handle regular printf-style formatting. A pragma is being used here to
+// suppress this warning:
+//
+// warning: function ‘std::__cxx11::string expand_message(const char*, __va_list_tag*)’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
+//
+// What appears to be happening here is that the checker is deciding that
+// because of the call to vasprintf() (which has attribute gnu_printf), the
+// calling function must need to have attribute gnu_printf as well, even
+// though there is already an attribute declaration for it.
+
+static std::string
+expand_message(const char* fmt, va_list ap) GO_ATTRIBUTE_GCC_DIAG(1,0);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+
+static std::string
+expand_message(const char* fmt, va_list ap)
+{
+ char* mbuf = 0;
+ std::string expanded_fmt = expand_format(fmt);
+ int nwr = vasprintf(&mbuf, expanded_fmt.c_str(), ap);
+ if (nwr == -1)
+ {
+ // memory allocation failed
+ go_be_error_at(Linemap::unknown_location(),
+ "memory allocation failed in vasprintf");
+ go_assert(0);
+ }
+ std::string rval = std::string(mbuf);
+ free(mbuf);
+ return rval;
+}
+
+#pragma GCC diagnostic pop
+
+static const char* cached_open_quote = NULL;
+static const char* cached_close_quote = NULL;
+
+const char*
+go_open_quote()
+{
+ if (cached_open_quote == NULL)
+ go_be_get_quotechars(&cached_open_quote, &cached_close_quote);
+ return cached_open_quote;
+}
+
+const char*
+go_close_quote()
+{
+ if (cached_close_quote == NULL)
+ go_be_get_quotechars(&cached_open_quote, &cached_close_quote);
+ return cached_close_quote;
+}
+
+void
+go_error_at(const Location location, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ go_be_error_at(location, expand_message(fmt, ap));
+ va_end(ap);
+}
+
+void
+go_warning_at(const Location location, int opt, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ go_be_warning_at(location, opt, expand_message(fmt, ap));
+ va_end(ap);
+}
+
+void
+go_fatal_error(const Location location, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ go_be_fatal_error(location, expand_message(fmt, ap));
+ va_end(ap);
+}
+
+void
+go_inform(const Location location, const char* fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ go_be_inform(location, expand_message(fmt, ap));
+ va_end(ap);
+}
--- /dev/null
+// go-diagnostics.h -- interface to diagnostic reporting -*- C++ -*-
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#ifndef GO_DIAGNOSTICS_H
+#define GO_DIAGNOSTICS_H
+
+#include "go-linemap.h"
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+#define GO_ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (__gcc_tdiag__, m, n))) __attribute__ ((__nonnull__ (m)))
+#else
+#define GO_ATTRIBUTE_GCC_DIAG(m, n)
+#endif
+
+// These declarations define the interface through which the frontend
+// reports errors and warnings. These functions accept printf-like
+// format specifiers (e.g. %d, %f, %s, etc), with the following additional
+// extensions:
+//
+// 1. 'q' qualifier may be applied to a specifier to add quoting, e.g.
+// %qd produces a quoted decimal output, %qs a quoted string output.
+// [This extension is supported only with single-character format
+// specifiers].
+//
+// 2. %m specifier outputs value of "strerror(errno)" at time of call.
+//
+// 3. %< outputs an opening quote, %> a closing quote.
+//
+// All other format specifiers are as defined by 'sprintf'. The final resulting
+// message is then sent to the back end via go_be_error_at/go_be_warning_at.
+
+extern void go_error_at(const Location, const char* fmt, ...)
+ GO_ATTRIBUTE_GCC_DIAG(2,3);
+extern void go_warning_at(const Location, int opt, const char* fmt, ...)
+ GO_ATTRIBUTE_GCC_DIAG(3,4);
+extern void go_fatal_error(const Location, const char* fmt, ...)
+ GO_ATTRIBUTE_GCC_DIAG(2,3);
+extern void go_inform(const Location, const char* fmt, ...)
+ GO_ATTRIBUTE_GCC_DIAG(2,3);
+
+// These interfaces provide a way for the front end to ask for
+// the open/close quote characters it should use when formatting
+// diagnostics (warnings, errors).
+extern const char* go_open_quote();
+extern const char* go_close_quote();
+
+// These interfaces are used by utilities above to pass warnings and
+// errors (once format specifiers have been expanded) to the back end,
+// and to determine quoting style. Avoid calling these routines directly;
+// instead use the equivalent routines above. The back end is required to
+// implement these routines.
+
+extern void go_be_error_at(const Location, const std::string& errmsg);
+extern void go_be_warning_at(const Location, int opt,
+ const std::string& warningmsg);
+extern void go_be_fatal_error(const Location, const std::string& errmsg);
+extern void go_be_inform(const Location, const std::string& infomsg);
+extern void go_be_get_quotechars(const char** open_quote,
+ const char** close_quote);
+
+#endif // !defined(GO_DIAGNOSTICS_H)
#include "go-system.h"
#include "go-c.h"
+#include "go-diagnostics.h"
#include "lex.h"
#include "parse.h"
{
file = fopen(filename, "r");
if (file == NULL)
- fatal_error(Linemap::unknown_location(),
- "cannot open %s: %m", filename);
+ go_fatal_error(Linemap::unknown_location(),
+ "cannot open %s: %m", filename);
}
Lex lexer(filename, file, ::gogo->linemap());
for (Lex::Linknames::const_iterator p = linknames->begin();
p != linknames->end();
++p)
- error_at(p->second.loc,
- ("//go:linkname only allowed in Go files that "
- "import \"unsafe\""));
+ go_error_at(p->second.loc,
+ ("//go:linkname only allowed in Go files that "
+ "import \"unsafe\""));
}
all_linknames.insert(linknames->begin(), linknames->end());
}
#include "filenames.h"
#include "go-c.h"
+#include "go-diagnostics.h"
#include "go-dump.h"
#include "go-optimize.h"
#include "lex.h"
if (this->package_ != NULL)
{
if (this->package_->package_name() != package_name)
- error_at(location, "expected package %<%s%>",
- Gogo::message_name(this->package_->package_name()).c_str());
+ go_error_at(location, "expected package %<%s%>",
+ Gogo::message_name(this->package_->package_name()).c_str());
return;
}
{
if (filename.empty())
{
- error_at(location, "import path is empty");
+ go_error_at(location, "import path is empty");
return;
}
int adv = Lex::fetch_char(pf, &c);
if (adv == 0)
{
- error_at(location, "import path contains invalid UTF-8 sequence");
+ go_error_at(location, "import path contains invalid UTF-8 sequence");
return;
}
if (c == '\0')
{
- error_at(location, "import path contains NUL");
+ go_error_at(location, "import path contains NUL");
return;
}
if (c < 0x20 || c == 0x7f)
{
- error_at(location, "import path contains control character");
+ go_error_at(location, "import path contains control character");
return;
}
if (c == '\\')
{
- error_at(location, "import path contains backslash; use slash");
+ go_error_at(location, "import path contains backslash; use slash");
return;
}
if (Lex::is_unicode_space(c))
{
- error_at(location, "import path contains space character");
+ go_error_at(location, "import path contains space character");
return;
}
if (c < 0x7f && strchr("!\"#$%&'()*,:;<=>?[]^`{|}", c) != NULL)
{
- error_at(location, "import path contains invalid character '%c'", c);
+ go_error_at(location,
+ "import path contains invalid character '%c'", c);
return;
}
pf += adv;
if (IS_ABSOLUTE_PATH(filename.c_str()))
{
- error_at(location, "import path cannot be absolute path");
+ go_error_at(location, "import path cannot be absolute path");
return;
}
if (local_name == "init")
- error_at(location, "cannot import package as init");
+ go_error_at(location, "cannot import package as init");
if (filename == "unsafe")
{
this->relative_import_path_);
if (stream == NULL)
{
- error_at(location, "import file %qs not found", filename.c_str());
+ go_error_at(location, "import file %qs not found", filename.c_str());
return;
}
if (package != NULL)
{
if (package->pkgpath() == this->pkgpath())
- error_at(location,
- ("imported package uses same package path as package "
- "being compiled (see -fgo-pkgpath option)"));
+ go_error_at(location,
+ ("imported package uses same package path as package "
+ "being compiled (see -fgo-pkgpath option)"));
this->imports_.insert(std::make_pair(filename, package));
}
// an error about it.
if (ii->package_name() != package_name)
{
- error("duplicate package initialization name %qs",
- Gogo::message_name(init_name).c_str());
- inform(UNKNOWN_LOCATION, "used by package %qs",
- Gogo::message_name(ii->package_name()).c_str());
- inform(UNKNOWN_LOCATION, " and by package %qs",
- Gogo::message_name(package_name).c_str());
+ go_error_at(Linemap::unknown_location(),
+ "duplicate package initialization name %qs",
+ Gogo::message_name(init_name).c_str());
+ go_inform(Linemap::unknown_location(), "used by package %qs",
+ Gogo::message_name(ii->package_name()).c_str());
+ go_inform(Linemap::unknown_location(), " and by package %qs",
+ Gogo::message_name(package_name).c_str());
}
ii->set_priority(prio);
return;
var);
if (ins.first->second)
{
- error_at(var->location(),
- ("initialization expressions for %qs and "
- "%qs depend upon each other"),
- var->message_name().c_str(),
- p2var->message_name().c_str());
- inform(p2->var()->location(), "%qs defined here",
- p2var->message_name().c_str());
+ go_error_at(var->location(),
+ ("initialization expressions for %qs and "
+ "%qs depend upon each other"),
+ var->message_name().c_str(),
+ p2var->message_name().c_str());
+ go_inform(p2->var()->location(), "%qs defined here",
+ p2var->message_name().c_str());
init_loop = true;
break;
}
Named_object* dep = gogo->var_depends_on(var->var_value());
if (init != NULL && dep == NULL
&& expression_requires(init, preinit, NULL, var))
- error_at(var->location(),
- "initialization expression for %qs depends upon itself",
- var->message_name().c_str());
+ go_error_at(var->location(),
+ "initialization expression for %qs depends upon itself",
+ var->message_name().c_str());
}
}
{
if (expression_requires(var->init(), NULL,
this->var_depends_on(var), no))
- error_at(no->location(),
- "initialization expression for %qs depends "
- "upon itself",
- no->message_name().c_str());
+ go_error_at(no->location(),
+ "initialization expression for %qs depends "
+ "upon itself",
+ no->message_name().c_str());
this->backend()->global_variable_set_init(bvar, var_binit);
}
else if (is_sink)
{
if ((type->parameters() != NULL && !type->parameters()->empty())
|| (type->results() != NULL && !type->results()->empty()))
- error_at(location,
- "func init must have no arguments and no return values");
+ go_error_at(location,
+ "func init must have no arguments and no return values");
// There can be multiple "init" functions, so give them each a
// different name.
static int init_count;
}
else
{
- error_at(type->receiver()->location(),
- "invalid receiver type (receiver must be a named type)");
+ go_error_at(type->receiver()->location(),
+ ("invalid receiver type (receiver must "
+ "be a named type)"));
ret = Named_object::make_function(name, NULL, function);
}
}
}
else
{
- error_at(type->receiver()->location(),
- "invalid receiver type (receiver must be a named type)");
+ go_error_at(type->receiver()->location(),
+ "invalid receiver type (receiver must be a named type)");
return Named_object::make_erroneous_name(name);
}
}
this->package_->bindings()->lookup(this->pack_hidden_name(go_name,
is_exported));
if (no == NULL)
- error_at(loc, "%s is not defined", go_name.c_str());
+ go_error_at(loc, "%s is not defined", go_name.c_str());
else if (no->is_function())
no->func_value()->set_asm_name(ext_name);
else if (no->is_function_declaration())
no->func_declaration_value()->set_asm_name(ext_name);
else
- error_at(loc,
- ("%s is not a function; "
- "//go:linkname is only supported for functions"),
- go_name.c_str());
+ go_error_at(loc,
+ ("%s is not a function; "
+ "//go:linkname is only supported for functions"),
+ go_name.c_str());
}
// Mark all local variables used. This is used when some types of
if (global_no->is_type())
{
if (no->type_declaration_value()->has_methods())
- error_at(no->location(),
- "may not define methods for global type");
+ go_error_at(no->location(),
+ "may not define methods for global type");
no->set_type_value(global_no->type_value());
}
else
{
- error_at(no->location(), "expected type");
+ go_error_at(no->location(), "expected type");
Type* errtype = Type::make_error_type();
Named_object* err =
Named_object::make_type("erroneous_type", NULL, errtype,
if (pf != this->file_block_names_.end())
{
std::string n = p->second->message_name();
- error_at(p->second->location(),
- "%qs defined as both imported name and global name",
- n.c_str());
- inform(pf->second, "%qs imported here", n.c_str());
+ go_error_at(p->second->location(),
+ "%qs defined as both imported name and global name",
+ n.c_str());
+ go_inform(pf->second, "%qs imported here", n.c_str());
}
// No package scope identifier may be named "init".
if (!p->second->is_function()
&& Gogo::unpack_hidden_name(p->second->name()) == "init")
{
- error_at(p->second->location(),
- "cannot declare init - must be func");
+ go_error_at(p->second->location(),
+ "cannot declare init - must be func");
}
}
}
std::string pkg_name = package->package_name();
if (p1->first != pkg_name && p1->first[0] != '.')
{
- error_at(p1->second->location(),
- "imported and not used: %s as %s",
- Gogo::message_name(pkg_name).c_str(),
- Gogo::message_name(p1->first).c_str());
+ go_error_at(p1->second->location(),
+ "imported and not used: %s as %s",
+ Gogo::message_name(pkg_name).c_str(),
+ Gogo::message_name(p1->first).c_str());
}
else
- error_at(p1->second->location(),
- "imported and not used: %s",
- Gogo::message_name(pkg_name).c_str());
+ go_error_at(p1->second->location(),
+ "imported and not used: %s",
+ Gogo::message_name(pkg_name).c_str());
}
}
}
&& !Type::are_assignable(var->type(), init->type(), &reason))
{
if (reason.empty())
- error_at(var->location(), "incompatible type in initialization");
+ go_error_at(var->location(), "incompatible type in initialization");
else
- error_at(var->location(),
- "incompatible type in initialization (%s)",
- reason.c_str());
+ go_error_at(var->location(),
+ "incompatible type in initialization (%s)",
+ reason.c_str());
init = Expression::make_error(named_object->location());
var->clear_init();
}
// initialization.
if (fntype->is_builtin())
{
- error_at(init->location(),
- "invalid use of special builtin function %qs; "
- "must be called",
- no->message_name().c_str());
+ go_error_at(init->location(),
+ "invalid use of special builtin function %qs; "
+ "must be called",
+ no->message_name().c_str());
}
}
if (!var->is_used()
&& !var->type()->is_error()
&& (init == NULL || !init->is_error_expression())
&& !Lex::is_invalid_identifier(named_object->name()))
- error_at(var->location(), "%qs declared and not used",
- named_object->message_name().c_str());
+ go_error_at(var->location(), "%qs declared and not used",
+ named_object->message_name().c_str());
}
return TRAVERSE_CONTINUE;
}
&& !ctype->is_string_type())
{
if (ctype->is_nil_type())
- error_at(constant->location(), "const initializer cannot be nil");
+ go_error_at(constant->location(), "const initializer cannot be nil");
else if (!ctype->is_error())
- error_at(constant->location(), "invalid constant type");
+ go_error_at(constant->location(), "invalid constant type");
constant->set_error();
}
else if (!constant->expr()->is_constant())
{
- error_at(constant->expr()->location(), "expression is not constant");
+ go_error_at(constant->expr()->location(), "expression is not constant");
constant->set_error();
}
else if (!Type::are_assignable(constant->type(), constant->expr()->type(),
NULL))
{
- error_at(constant->location(),
- "initialization expression has wrong type");
+ go_error_at(constant->location(),
+ "initialization expression has wrong type");
constant->set_error();
}
return TRAVERSE_CONTINUE;
return TRAVERSE_CONTINUE;
if (func->block()->may_fall_through())
- error_at(func->block()->end_location(),
- "missing return at end of function");
+ go_error_at(func->block()->end_location(),
+ "missing return at end of function");
return TRAVERSE_CONTINUE;
}
out.open(this->c_header_.c_str());
if (out.fail())
{
- error("cannot open %s: %m", this->c_header_.c_str());
+ go_error_at(Linemap::unknown_location(),
+ "cannot open %s: %m", this->c_header_.c_str());
return;
}
out.close();
if (out.fail())
- error("error writing to %s: %m", this->c_header_.c_str());
+ go_error_at(Linemap::unknown_location(),
+ "error writing to %s: %m", this->c_header_.c_str());
}
// Find the blocks in order to convert named types defined in blocks.
label = ins.first->second;
if (label->is_defined())
{
- error_at(location, "label %qs already defined",
- Gogo::message_name(label_name).c_str());
- inform(label->location(), "previous definition of %qs was here",
- Gogo::message_name(label_name).c_str());
+ go_error_at(location, "label %qs already defined",
+ Gogo::message_name(label_name).c_str());
+ go_inform(label->location(), "previous definition of %qs was here",
+ Gogo::message_name(label_name).c_str());
return new Label(label_name);
}
}
{
Label* label = p->second;
if (!label->is_used())
- error_at(label->location(), "label %qs defined and not used",
- Gogo::message_name(label->name()).c_str());
+ go_error_at(label->location(), "label %qs defined and not used",
+ Gogo::message_name(label->name()).c_str());
}
}
? NULL
: enclosing->bindings())),
start_location_(location),
- end_location_(UNKNOWN_LOCATION)
+ end_location_(Linemap::unknown_location())
{
}
{
if (pb == NULL)
{
- error_at(loc, "goto jumps into block");
- inform(bto->start_location(), "goto target block starts here");
+ go_error_at(loc, "goto jumps into block");
+ go_inform(bto->start_location(), "goto target block starts here");
return false;
}
}
go_assert(p != block->bindings()->end_definitions());
std::string n = (*p)->message_name();
- error_at(loc, "goto jumps over declaration of %qs", n.c_str());
- inform((*p)->location(), "%qs defined here", n.c_str());
+ go_error_at(loc, "goto jumps over declaration of %qs", n.c_str());
+ go_inform((*p)->location(), "%qs defined here", n.c_str());
}
}
else
{
if (report_error)
- error_at(this->location(), "invalid tuple definition");
+ go_error_at(this->location(), "invalid tuple definition");
return Type::make_error_type();
}
}
else
{
if (report_error)
- error_at(this->location(),
- "invalid definition of value variable for channel range");
+ go_error_at(this->location(),
+ ("invalid definition of value variable "
+ "for channel range"));
return Type::make_error_type();
}
}
else
{
if (report_error)
- error_at(this->location(), "invalid type for range clause");
+ go_error_at(this->location(), "invalid type for range clause");
return Type::make_error_type();
}
}
else
{
if (report_error)
- error_at(this->location(), "expected channel");
+ go_error_at(this->location(), "expected channel");
return Type::make_error_type();
}
}
{
if (this->type_ == NULL || !this->type_->is_error_type())
{
- error_at(this->location_, "variable initializer refers to itself");
+ go_error_at(this->location_, "variable initializer refers to itself");
this->type_ = Type::make_error_type();
}
return this->type_;
if (type->is_void_type())
{
- error_at(this->location_, "variable has no type");
+ go_error_at(this->location_, "variable has no type");
type = Type::make_error_type();
}
else if (type->is_nil_type())
{
- error_at(this->location_, "variable defined to nil type");
+ go_error_at(this->location_, "variable defined to nil type");
type = Type::make_error_type();
}
else if (type->is_call_multiple_result_type())
{
- error_at(this->location_,
+ go_error_at(this->location_,
"single variable set to multiple-value function call");
type = Type::make_error_type();
}
break;
case NAMED_OBJECT_TYPE_DECLARATION:
- error_at(this->type_declaration_value()->location(),
- "attempt to export %<%s%> which was declared but not defined",
- this->message_name().c_str());
+ go_error_at(this->type_declaration_value()->location(),
+ "attempt to export %<%s%> which was declared but not defined",
+ this->message_name().c_str());
break;
case NAMED_OBJECT_FUNC_DECLARATION:
break;
case NAMED_OBJECT_TYPE_DECLARATION:
- error("reference to undefined type %qs",
- this->message_name().c_str());
+ go_error_at(Linemap::unknown_location(),
+ "reference to undefined type %qs",
+ this->message_name().c_str());
return;
case NAMED_OBJECT_VAR:
if (new_object->is_function_declaration())
{
if (!new_object->func_declaration_value()->asm_name().empty())
- sorry("__asm__ for function definitions");
+ go_error_at(Linemap::unknown_location(),
+ ("sorry, not implemented: "
+ "__asm__ for function definitions"));
Function_type* old_type = old_object->func_value()->type();
Function_type* new_type =
new_object->func_declaration_value()->type();
if (old_type->is_valid_redeclaration(new_type, &reason))
{
if (!old_object->func_declaration_value()->asm_name().empty())
- sorry("__asm__ for function definitions");
+ go_error_at(Linemap::unknown_location(),
+ ("sorry, not implemented: "
+ "__asm__ for function definitions"));
old_object->set_function_value(new_object->func_value());
this->named_objects_.push_back(old_object);
return old_object;
std::string n = old_object->message_name();
if (reason.empty())
- error_at(new_object->location(), "redefinition of %qs", n.c_str());
+ go_error_at(new_object->location(), "redefinition of %qs", n.c_str());
else
- error_at(new_object->location(), "redefinition of %qs: %s", n.c_str(),
- reason.c_str());
+ go_error_at(new_object->location(), "redefinition of %qs: %s", n.c_str(),
+ reason.c_str());
old_object->set_is_redefinition();
new_object->set_is_redefinition();
- inform(old_object->location(), "previous definition of %qs was here",
- n.c_str());
+ go_inform(old_object->location(), "previous definition of %qs was here",
+ n.c_str());
return old_object;
}
if (this->package_name_.empty())
this->package_name_ = package_name;
else if (this->package_name_ != package_name)
- error_at(location,
- "saw two different packages with the same package path %s: %s, %s",
- this->pkgpath_.c_str(), this->package_name_.c_str(),
- package_name.c_str());
+ go_error_at(location,
+ ("saw two different packages with "
+ "the same package path %s: %s, %s"),
+ this->pkgpath_.c_str(), this->package_name_.c_str(),
+ package_name.c_str());
}
// Return the pkgpath symbol, which is a prefix for symbols defined in
this->fake_uses_.erase(p);
if (this->fake_uses_.empty())
- error_at(this->location(), "imported and not used: %s",
- Gogo::message_name(this->package_name()).c_str());
+ go_error_at(this->location(), "imported and not used: %s",
+ Gogo::message_name(this->package_name()).c_str());
}
// Clear the used field for the next file. If the only usages of this package
#include "go-system.h"
+#include "go-diagnostics.h"
#include "import.h"
#ifndef O_BINARY
struct stat st;
if (fstat(this->fd_, &st) < 0)
{
- error_at(this->location_, "%s: %m", this->filename_.c_str());
+ go_error_at(this->location_, "%s: %m", this->filename_.c_str());
return false;
}
this->filesize_ = st.st_size;
if (::lseek(this->fd_, 0, SEEK_SET) < 0
|| ::read(this->fd_, buf, sizeof(armagt)) != sizeof(armagt))
{
- error_at(this->location_, "%s: %m", this->filename_.c_str());
+ go_error_at(this->location_, "%s: %m", this->filename_.c_str());
return false;
}
this->is_thin_archive_ = memcmp(buf, armagt, sizeof(armagt)) == 0;
char* rdbuf = new char[size];
if (::read(this->fd_, rdbuf, size) != size)
{
- error_at(this->location_, "%s: could not read extended names",
+ go_error_at(this->location_, "%s: could not read extended names",
filename.c_str());
delete[] rdbuf;
return false;
if (::lseek(this->fd_, offset, SEEK_SET) < 0
|| ::read(this->fd_, buf, size) != size)
{
- error_at(this->location_, "%s: %m", this->filename_.c_str());
+ go_error_at(this->location_, "%s: %m", this->filename_.c_str());
return false;
}
return true;
Archive_header hdr;
if (::lseek(this->fd_, off, SEEK_SET) < 0)
{
- error_at(this->location_, "%s: %m", this->filename_.c_str());
+ go_error_at(this->location_, "%s: %m", this->filename_.c_str());
return false;
}
ssize_t got = ::read(this->fd_, &hdr, sizeof hdr);
if (got != sizeof hdr)
{
if (got < 0)
- error_at(this->location_, "%s: %m", this->filename_.c_str());
+ go_error_at(this->location_, "%s: %m", this->filename_.c_str());
else if (got > 0)
- error_at(this->location_, "%s: short archive header at %ld",
- this->filename_.c_str(), static_cast<long>(off));
+ go_error_at(this->location_, "%s: short archive header at %ld",
+ this->filename_.c_str(), static_cast<long>(off));
else
- error_at(this->location_, "%s: unexpected EOF at %ld",
- this->filename_.c_str(), static_cast<long>(off));
+ go_error_at(this->location_, "%s: unexpected EOF at %ld",
+ this->filename_.c_str(), static_cast<long>(off));
}
off_t local_nested_off;
if (!this->interpret_header(&hdr, off, pname, size, &local_nested_off))
{
if (memcmp(hdr->ar_fmag, arfmag, sizeof arfmag) != 0)
{
- error_at(this->location_, "%s: malformed archive header at %lu",
- this->filename_.c_str(), static_cast<unsigned long>(off));
+ go_error_at(this->location_, "%s: malformed archive header at %lu",
+ this->filename_.c_str(), static_cast<unsigned long>(off));
return false;
}
|| *size < 0
|| (*size == LONG_MAX && errno == ERANGE))
{
- error_at(this->location_, "%s: malformed archive header size at %lu",
- this->filename_.c_str(), static_cast<unsigned long>(off));
+ go_error_at(this->location_, "%s: malformed archive header size at %lu",
+ this->filename_.c_str(), static_cast<unsigned long>(off));
return false;
}
if (name_end == NULL
|| name_end - hdr->ar_name >= static_cast<int>(sizeof hdr->ar_name))
{
- error_at(this->location_, "%s: malformed archive header name at %lu",
- this->filename_.c_str(), static_cast<unsigned long>(off));
+ go_error_at(this->location_,
+ "%s: malformed archive header name at %lu",
+ this->filename_.c_str(), static_cast<unsigned long>(off));
return false;
}
pname->assign(hdr->ar_name, name_end - hdr->ar_name);
|| (x == LONG_MAX && errno == ERANGE)
|| static_cast<size_t>(x) >= this->extended_names_.size())
{
- error_at(this->location_, "%s: bad extended name index at %lu",
- this->filename_.c_str(), static_cast<unsigned long>(off));
+ go_error_at(this->location_, "%s: bad extended name index at %lu",
+ this->filename_.c_str(), static_cast<unsigned long>(off));
return false;
}
if (static_cast<size_t>(name_end - name) > this->extended_names_.size()
|| name_end[-1] != '/')
{
- error_at(this->location_, "%s: bad extended name entry at header %lu",
- this->filename_.c_str(), static_cast<unsigned long>(off));
+ go_error_at(this->location_,
+ "%s: bad extended name entry at header %lu",
+ this->filename_.c_str(), static_cast<unsigned long>(off));
return false;
}
pname->assign(name, name_end - 1 - name);
int nfd = open(filename.c_str(), O_RDONLY | O_BINARY);
if (nfd < 0)
{
- error_at(this->location_, "%s: can't open nested archive %s",
- this->filename_.c_str(), filename.c_str());
+ go_error_at(this->location_, "%s: can't open nested archive %s",
+ this->filename_.c_str(), filename.c_str());
return false;
}
nfile = new Archive_file(filename, nfd, this->location_);
*memfd = open(filename.c_str(), O_RDONLY | O_BINARY);
if (*memfd < 0)
{
- error_at(this->location_, "%s: %m", filename.c_str());
+ go_error_at(this->location_, "%s: %m", filename.c_str());
return false;
}
*memoff = 0;
{
if (filesize != this->off_)
{
- error_at(this->afile_->location(),
- "%s: short archive header at %lu",
- this->afile_->filename().c_str(),
- static_cast<unsigned long>(this->off_));
+ go_error_at(this->afile_->location(),
+ "%s: short archive header at %lu",
+ this->afile_->filename().c_str(),
+ static_cast<unsigned long>(this->off_));
this->off_ = filesize;
}
this->header_.off = filesize;
#include "filenames.h"
#include "go-c.h"
+#include "go-diagnostics.h"
#include "gogo.h"
#include "lex.h"
#include "types.h"
if (fd < 0)
{
if (errno != ENOENT && errno != EISDIR)
- warning_at(location, 0, "%s: %m", filename.c_str());
+ go_warning_at(location, 0, "%s: %m", filename.c_str());
fd = Import::try_suffixes(&found_filename);
if (fd < 0)
close(fd);
- error_at(location, "%s exists but does not contain any Go export data",
- found_filename.c_str());
+ go_error_at(location, "%s exists but does not contain any Go export data",
+ found_filename.c_str());
return NULL;
}
if (lseek(fd, 0, SEEK_SET) < 0)
{
- error_at(location, "lseek %s failed: %m", filename.c_str());
+ go_error_at(location, "lseek %s failed: %m", filename.c_str());
return NULL;
}
if (errmsg != NULL)
{
if (err == 0)
- error_at(location, "%s: %s", filename.c_str(), errmsg);
+ go_error_at(location, "%s: %s", filename.c_str(), errmsg);
else
- error_at(location, "%s: %s: %s", filename.c_str(), errmsg,
- xstrerror(err));
+ go_error_at(location, "%s: %s: %s", filename.c_str(), errmsg,
+ xstrerror(err));
return NULL;
}
}
else
{
- error_at(this->location_,
- ("error in import data at %d: invalid magic string"),
- stream->pos());
+ go_error_at(this->location_,
+ ("error in import data at %d: invalid magic string"),
+ stream->pos());
return NULL;
}
break;
else
{
- error_at(this->location_,
- ("error in import data at %d: "
- "expected %<const%>, %<type%>, %<var%>, "
- "%<func%>, or %<checksum%>"),
- stream->pos());
+ go_error_at(this->location_,
+ ("error in import data at %d: "
+ "expected %<const%>, %<type%>, %<var%>, "
+ "%<func%>, or %<checksum%>"),
+ stream->pos());
stream->set_saw_error();
return NULL;
}
: (static_cast<size_t>(index) >= this->types_.size()
|| this->types_[index] == NULL))
{
- error_at(this->location_,
- "error in import data at %d: bad type index %d",
- stream->pos(), index);
+ go_error_at(this->location_,
+ "error in import data at %d: bad type index %d",
+ stream->pos(), index);
stream->set_saw_error();
return Type::make_error_type();
}
if (c != ' ')
{
if (!stream->saw_error())
- error_at(this->location_,
- "error in import data at %d: expect %< %> or %<>%>'",
- stream->pos());
+ go_error_at(this->location_,
+ "error in import data at %d: expect %< %> or %<>%>'",
+ stream->pos());
stream->set_saw_error();
stream->advance(1);
return Type::make_error_type();
|| (static_cast<size_t>(index) < this->types_.size()
&& this->types_[index] != NULL))
{
- error_at(this->location_,
- "error in import data at %d: type index already defined",
- stream->pos());
+ go_error_at(this->location_,
+ "error in import data at %d: type index already defined",
+ stream->pos());
stream->set_saw_error();
return Type::make_error_type();
}
no = package->add_type_declaration(type_name, this->location_);
else if (!no->is_type_declaration() && !no->is_type())
{
- error_at(this->location_, "imported %<%s.%s%> both type and non-type",
- pkgpath.c_str(), Gogo::message_name(type_name).c_str());
+ go_error_at(this->location_, "imported %<%s.%s%> both type and non-type",
+ pkgpath.c_str(), Gogo::message_name(type_name).c_str());
stream->set_saw_error();
return Type::make_error_type();
}
if (c != '>')
{
- error_at(this->location(),
- "error in import data at %d: expect %< %> or %<>%>, got %c",
- stream->pos(), c);
+ go_error_at(this->location(),
+ ("error in import data at %d: "
+ "expect %< %> or %<>%>, got %c"),
+ stream->pos(), c);
stream->set_saw_error();
stream->advance(1);
escape = Escape_note::make_tag(Node::ESCAPE_UNKNOWN);
long prio = strtol(s.c_str(), &end, 10);
if (*end != '\0' || prio > 0x7fffffff || (prio < 0 && !is_neg_ok))
{
- error_at(this->location_, "invalid integer in import data at %d",
- this->stream_->pos());
+ go_error_at(this->location_, "invalid integer in import data at %d",
+ this->stream_->pos());
this->stream_->set_saw_error();
return false;
}
|| memcmp(bytes, read, length) != 0)
{
if (!this->saw_error_)
- error_at(location, "import error at %d: expected %<%.*s%>",
- this->pos(), static_cast<int>(length), bytes);
+ go_error_at(location, "import error at %d: expected %<%.*s%>",
+ this->pos(), static_cast<int>(length), bytes);
this->saw_error_ = true;
return;
}
{
if (lseek(fd, 0, SEEK_SET) != 0)
{
- error("lseek failed: %m");
+ go_fatal_error(Linemap::unknown_location(), "lseek failed: %m");
this->set_saw_error();
}
}
if (got < 0)
{
if (!this->saw_error())
- error("read failed: %m");
+ go_fatal_error(Linemap::unknown_location(), "read failed: %m");
this->set_saw_error();
return false;
}
if (lseek(this->fd_, - got, SEEK_CUR) != 0)
{
if (!this->saw_error())
- error("lseek failed: %m");
+ go_fatal_error(Linemap::unknown_location(), "lseek failed: %m");
this->set_saw_error();
return false;
}
if (lseek(this->fd_, skip, SEEK_CUR) != 0)
{
if (!this->saw_error())
- error("lseek failed: %m");
+ go_fatal_error(Linemap::unknown_location(), "lseek failed: %m");
this->set_saw_error();
}
if (!this->data_.empty())
// license that can be found in the LICENSE file.
#include "go-system.h"
+#include "go-diagnostics.h"
#include "lex.h"
{
size_t ns = 2 * size + 1;
if (ns < size || static_cast<ssize_t>(ns) < 0)
- error_at(this->location(), "out of memory");
+ go_error_at(this->location(), "out of memory");
char* nb = new char[ns];
memcpy(nb, buf, cur);
delete[] buf;
return this->gather_identifier();
if (!issued_error)
- error_at(this->location(),
- "invalid character 0x%x in input file",
- ci);
+ go_error_at(this->location(),
+ "invalid character 0x%x in input file",
+ ci);
p = pend;
if (*p == '\0')
{
- error_at(this->location(), "invalid NUL byte");
+ go_error_at(this->location(), "invalid NUL byte");
*issued_error = true;
*value = 0;
return p + 1;
int adv = Lex::fetch_char(p, value);
if (adv == 0)
{
- error_at(this->location(), "invalid UTF-8 encoding");
+ go_error_at(this->location(), "invalid UTF-8 encoding");
*issued_error = true;
return p + 1;
}
// Warn about byte order mark, except at start of file.
if (*value == 0xfeff && (this->lineno_ != 1 || this->lineoff_ != 0))
{
- error_at(this->location(), "Unicode (UTF-8) BOM in middle of file");
+ go_error_at(this->location(), "Unicode (UTF-8) BOM in middle of file");
*issued_error = true;
}
break;
this->lineoff_ = p - this->linebuf_;
- error_at(this->location(),
- "invalid character 0x%x in identifier",
- cc);
+ go_error_at(this->location(),
+ "invalid character 0x%x in identifier",
+ cc);
if (!has_non_ascii_char)
{
buf.assign(pstart, p - pstart);
// handling behavior if we swallow this character after
// giving an error.
if (!issued_error)
- error_at(this->location(),
- "invalid character 0x%x in identifier",
- ci);
+ go_error_at(this->location(),
+ "invalid character 0x%x in identifier",
+ ci);
is_invalid = true;
}
if (is_first)
if (r != 0)
{
if (base == 8)
- error_at(this->location(), "invalid octal literal");
+ go_error_at(this->location(), "invalid octal literal");
else
- error_at(this->location(), "invalid hex literal");
+ go_error_at(this->location(), "invalid hex literal");
}
if (neg)
if (is_single_quote
&& (*value == '\'' || *value == '\n')
&& !issued_error)
- error_at(this->location(), "invalid character literal");
+ go_error_at(this->location(), "invalid character literal");
return ret;
}
else
+ Lex::octal_value(p[2]));
if (*value > 255)
{
- error_at(this->location(), "invalid octal constant");
+ go_error_at(this->location(), "invalid octal constant");
*value = 255;
}
return p + 3;
}
- error_at(this->location(), "invalid octal character");
+ go_error_at(this->location(), "invalid octal character");
return (p[1] >= '0' && p[1] <= '7'
? p + 2
: p + 1);
*value = (Lex::hex_val(p[1]) << 4) + Lex::hex_val(p[2]);
return p + 3;
}
- error_at(this->location(), "invalid hex character");
+ go_error_at(this->location(), "invalid hex character");
return (Lex::is_hex_digit(p[1])
? p + 2
: p + 1);
return p + 1;
case '\'':
if (!is_single_quote)
- error_at(this->location(), "invalid quoted character");
+ go_error_at(this->location(), "invalid quoted character");
*value = '\'';
return p + 1;
case '"':
if (is_single_quote)
- error_at(this->location(), "invalid quoted character");
+ go_error_at(this->location(), "invalid quoted character");
*value = '"';
return p + 1;
+ Lex::hex_val(p[4]));
if (*value >= 0xd800 && *value < 0xe000)
{
- error_at(this->location(),
- "invalid unicode code point 0x%x",
- *value);
+ go_error_at(this->location(),
+ "invalid unicode code point 0x%x",
+ *value);
// Use the replacement character.
*value = 0xfffd;
}
return p + 5;
}
- error_at(this->location(), "invalid little unicode code point");
+ go_error_at(this->location(), "invalid little unicode code point");
return p + 1;
case 'U':
if (*value > 0x10ffff
|| (*value >= 0xd800 && *value < 0xe000))
{
- error_at(this->location(), "invalid unicode code point 0x%x",
- *value);
+ go_error_at(this->location(),
+ "invalid unicode code point 0x%x",
+ *value);
// Use the replacement character.
*value = 0xfffd;
}
return p + 9;
}
- error_at(this->location(), "invalid big unicode code point");
+ go_error_at(this->location(), "invalid big unicode code point");
return p + 1;
default:
- error_at(this->location(), "invalid character after %<\\%>");
+ go_error_at(this->location(), "invalid character after %<\\%>");
*value = *p;
return p + 1;
}
{
if (v > 0x10ffff)
{
- warning_at(location, 0,
- "unicode code point 0x%x out of range in string", v);
+ go_warning_at(location, 0,
+ "unicode code point 0x%x out of range in string", v);
// Turn it into the "replacement character".
v = 0xfffd;
}
if (v >= 0xd800 && v < 0xe000)
{
- warning_at(location, 0,
- "unicode code point 0x%x is invalid surrogate pair", v);
+ go_warning_at(location, 0,
+ "unicode code point 0x%x is invalid surrogate pair", v);
v = 0xfffd;
}
if (v <= 0xffff)
if (*p != '\'')
{
- error_at(this->location(), "unterminated character constant");
+ go_error_at(this->location(), "unterminated character constant");
this->lineoff_ = p - this->linebuf_;
return this->make_invalid_token();
}
p = this->advance_one_char(p, false, &c, &is_character);
if (p >= pend)
{
- error_at(this->location(), "unterminated string");
+ go_error_at(this->location(), "unterminated string");
--p;
break;
}
this->lineoff_ = p - this->linebuf_;
if (!this->require_line())
{
- error_at(location, "unterminated raw string");
+ go_error_at(location, "unterminated raw string");
return Token::make_string_token(value, location);
}
p = this->linebuf_ + this->lineoff_;
{
if (!this->require_line())
{
- error_at(this->location(), "unterminated comment");
+ go_error_at(this->location(), "unterminated comment");
return false;
}
}
}
if (go_name.empty() || ext_name.empty())
- error_at(loc, "usage: //go:linkname localname linkname");
+ go_error_at(loc, "usage: //go:linkname localname linkname");
else
{
if (this->linknames_ == NULL)
#include "lex.h"
#include "gogo.h"
+#include "go-diagnostics.h"
#include "types.h"
#include "statements.h"
#include "expressions.h"
{
if (!token->is_identifier())
{
- error_at(this->location(), "expected identifier");
+ go_error_at(this->location(), "expected identifier");
return;
}
std::string name =
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;
}
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();
token = this->advance_token();
if (!token->is_identifier())
{
- error_at(this->location(), "expected identifier");
+ go_error_at(this->location(), "expected identifier");
return false;
}
if (name == "_")
{
- error_at(this->location(), "invalid use of %<_%>");
+ go_error_at(this->location(), "invalid use of %<_%>");
name = Gogo::erroneous_name();
}
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();
}
}
{
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;
}
}
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;
}
if (!ok)
{
if (issue_error)
- error_at(location, "expected type");
+ go_error_at(location, "expected type");
return Type::make_error_type();
}
}
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();
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();
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();
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();
}
}
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();
}
{
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());
}
}
}
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)
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)
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 =
{
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;
{
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();
}
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());
}
}
}
if (!this->peek_token()->is_op(OPERATOR_LPAREN))
{
- error_at(this->location(), "expected %<(%>");
+ go_error_at(this->location(), "expected %<(%>");
return false;
}
if (!token->is_op(OPERATOR_RPAREN))
{
- error_at(this->location(), "expected %<)%>");
+ go_error_at(this->location(), "expected %<)%>");
return false;
}
this->advance_token();
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();
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();
}
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,
}
if (mix_error)
{
- error_at(location, "invalid named/anonymous mix");
+ go_error_at(location, "invalid named/anonymous mix");
saw_error = true;
}
if (saw_error)
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();
{
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
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();
}
}
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();
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();
}
}
}
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())
const Token* token = this->peek_token();
if (!token->is_identifier())
{
- error_at(this->location(), "expected identifier");
+ go_error_at(this->location(), "expected identifier");
return;
}
{
// 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)
&& !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()
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();
this->function_decl(pragmas);
else
{
- error_at(this->location(), "expected declaration");
+ go_error_at(this->location(), "expected declaration");
this->advance_token();
}
}
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;
}
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())
|| 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);
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;
}
{
if (*last_expr_list == NULL)
{
- error_at(this->location(), "expected %<=%>");
+ go_error_at(this->location(), "expected %<=%>");
return;
}
type = *last_type;
{
if (pe == expr_list->end())
{
- error_at(this->location(), "not enough initializers");
+ go_error_at(this->location(), "not enough initializers");
return;
}
if (type != NULL)
}
}
if (pe != expr_list->end())
- error_at(this->location(), "too many initializers");
+ go_error_at(this->location(), "too many initializers");
this->increment_iota();
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();
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();
}
&& (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();
}
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();
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);
}
}
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);
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);
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,
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);
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
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))
{
if (!token->is_identifier())
{
- error_at(this->location(), "expected function name");
+ go_error_at(this->location(), "expected function name");
return;
}
{
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();
{
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));
{
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;
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
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();
&& !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);
}
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);
}
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:
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)
break;
}
- error_at(this->location(), "expected operand");
+ go_error_at(this->location(), "expected operand");
return Expression::make_error(this->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;
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))
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())
&& 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
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();
*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)
}
else
{
- error_at(this->location(), "expected identifier or %<(%>");
+ go_error_at(this->location(), "expected identifier or %<(%>");
return left;
}
}
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
{
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);
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());
}
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);
}
}
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())
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;
this->for_stat(label);
break;
default:
- error_at(this->location(), "expected statement");
+ go_error_at(this->location(), "expected statement");
this->advance_token();
break;
}
break;
default:
- error_at(this->location(), "expected statement");
+ go_error_at(this->location(), "expected statement");
this->advance_token();
break;
}
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;
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())
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;
}
&& !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();
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;
}
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();
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
&& (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;
&& (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,
&& (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();
&& (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();
}
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"));
}
}
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;
}
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());
}
}
}
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)
{
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.
}
{
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,
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());
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))
{
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);
}
}
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);
}
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);
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);
if (!this->peek_token()->is_op(OPERATOR_COLON))
{
if (!saw_errors())
- error_at(this->location(), "expected %<:%>");
+ go_error_at(this->location(), "expected %<:%>");
return;
}
else
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;
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;
{
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
{
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,
}
}
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;
}
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();
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();
}
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;
}
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();
}
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;
}
}
{
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);
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());
{
if (*saw_default)
{
- error_at(location, "multiple defaults in select");
+ go_error_at(location, "multiple defaults in select");
return;
}
*saw_default = true;
}
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;
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;
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;
{
if (!this->advance_token()->is_op(OPERATOR_CHANOP))
{
- error_at(this->location(), "missing %<<-%>");
+ go_error_at(this->location(), "missing %<<-%>");
return false;
}
*is_send = false;
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;
}
return true;
}
- error_at(this->location(), "expected %<<-%> or %<=%>");
+ go_error_at(this->location(), "expected %<<-%> or %<=%>");
return false;
}
{
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();
}
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)
{
{
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.
}
*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;
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();
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,
}
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
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,
{
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;
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;
}
{
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;
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;
}
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(),
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
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";
}
}
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;
}
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))
{
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())
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();
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);
}
}
{
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());
}
Expression* expr;
Type_switch()
- : found(false), name(), location(UNKNOWN_LOCATION), expr(NULL)
+ : found(false), name(), location(Linemap::unknown_location()),
+ expr(NULL)
{ }
};
#include "go-system.h"
#include "go-c.h"
+#include "go-diagnostics.h"
#include "types.h"
#include "expressions.h"
#include "gogo.h"
void
Statement::report_error(const char* msg)
{
- error_at(this->location_, "%s", msg);
+ go_error_at(this->location_, "%s", msg);
this->set_is_error();
}
if (!Type::are_assignable(this->type_, this->init_->type(), &reason))
{
if (reason.empty())
- error_at(this->location(), "incompatible types in assignment");
+ go_error_at(this->location(), "incompatible types in assignment");
else
- error_at(this->location(), "incompatible types in assignment (%s)",
+ go_error_at(this->location(), "incompatible types in assignment (%s)",
reason.c_str());
this->set_is_error();
}
if (!Type::are_assignable(lhs_type, rhs_type, &reason))
{
if (reason.empty())
- error_at(this->location(), "incompatible types in assignment");
+ go_error_at(this->location(), "incompatible types in assignment");
else
- error_at(this->location(), "incompatible types in assignment (%s)",
- reason.c_str());
+ go_error_at(this->location(), "incompatible types in assignment (%s)",
+ reason.c_str());
this->set_is_error();
}
else
{
if (reason.empty())
- error_at(e->location(), "incompatible type for return value %d", i);
+ go_error_at(e->location(),
+ "incompatible type for return value %d", i);
else
- error_at(e->location(),
- "incompatible type for return value %d (%s)",
- i, reason.c_str());
+ go_error_at(e->location(),
+ "incompatible type for return value %d (%s)",
+ i, reason.c_str());
}
}
go_assert(lhs->size() == rhs->size());
{
if (!this->label_->is_defined())
{
- error_at(this->location(), "reference to undefined label %qs",
- Gogo::message_name(this->label_->name()).c_str());
+ go_error_at(this->location(), "reference to undefined label %qs",
+ Gogo::message_name(this->label_->name()).c_str());
this->set_is_error();
}
}
if (!Type::are_assignable(type, (*p)->type(), NULL)
&& !Type::are_assignable((*p)->type(), type, NULL))
{
- error_at((*p)->location(),
- "type mismatch between switch value and case clause");
+ go_error_at((*p)->location(),
+ "type mismatch between switch value and case clause");
return false;
}
}
if (!ins.second)
{
// Value was already present.
- error_at(this->location_, "duplicate case in switch");
+ go_error_at(this->location_, "duplicate case in switch");
e = Expression::make_error(this->location_);
}
cases->push_back(e->get_backend(context));
&& !Type::are_compatible_for_comparison(true, this->val_->type(),
Type::make_nil_type(), NULL))
{
- error_at(this->val_->location(),
- "cannot switch on value whose type that may not be compared");
+ go_error_at(this->val_->location(),
+ "cannot switch on value whose type that may not be compared");
return Statement::make_error_statement(loc);
}
&reason))
{
if (reason.empty())
- error_at(this->location_, "impossible type switch case");
+ go_error_at(this->location_, "impossible type switch case");
else
- error_at(this->location_, "impossible type switch case (%s)",
- reason.c_str());
+ go_error_at(this->location_, "impossible type switch case (%s)",
+ reason.c_str());
}
Expression* ref = Expression::make_temporary_reference(descriptor_temp,
t = Type::make_nil_type();
std::pair<Types_seen::iterator, bool> ins = types_seen.insert(t);
if (!ins.second)
- error_at(p->location(), "duplicate type in switch");
+ go_error_at(p->location(), "duplicate type in switch");
}
}
Channel_type* channel_type = type->channel_type();
if (channel_type == NULL)
{
- error_at(this->location(), "left operand of %<<-%> must be channel");
+ go_error_at(this->location(), "left operand of %<<-%> must be channel");
this->set_is_error();
return;
}
Channel_type* ct = this->channel_->type()->channel_type();
if (ct == NULL)
{
- error_at(this->channel_->location(), "expected channel");
+ go_error_at(this->channel_->location(), "expected channel");
return;
}
if (this->is_send_ && !ct->may_send())
- error_at(this->location(), "invalid send on receive-only channel");
+ go_error_at(this->location(), "invalid send on receive-only channel");
else if (!this->is_send_ && !ct->may_receive())
- error_at(this->location(), "invalid receive on send-only channel");
+ go_error_at(this->location(), "invalid receive on send-only channel");
}
// Whether this clause may fall through to the statement which follows
public:
Case_clause()
: cases_(NULL), statements_(NULL), is_default_(false),
- is_fallthrough_(false), location_(UNKNOWN_LOCATION)
+ is_fallthrough_(false), location_(Linemap::unknown_location())
{ }
Case_clause(Expression_list* cases, bool is_default, Block* statements,
public:
Type_case_clause()
: type_(NULL), statements_(NULL), is_default_(false),
- location_(UNKNOWN_LOCATION)
+ location_(Linemap::unknown_location())
{ }
Type_case_clause(Type* type, bool is_fallthrough, bool is_default,
#include "go-c.h"
#include "gogo.h"
+#include "go-diagnostics.h"
#include "operator.h"
#include "expressions.h"
#include "statements.h"
if (*psize == -1)
{
if (this->named_type() != NULL)
- error_at(this->named_type()->location(),
- "type %s larger than address space",
- Gogo::message_name(this->named_type()->name()).c_str());
+ go_error_at(this->named_type()->location(),
+ "type %s larger than address space",
+ Gogo::message_name(this->named_type()->name()).c_str());
else
- error("type %s larger than address space",
- this->reflection(gogo).c_str());
+ go_error_at(Linemap::unknown_location(),
+ "type %s larger than address space",
+ this->reflection(gogo).c_str());
// Make this an error type to avoid knock-on errors.
this->classification_ = TYPE_ERROR;
return Interface_type::do_import(imp);
else
{
- error_at(imp->location(), "import error: expected type");
+ go_error_at(imp->location(), "import error: expected type");
return Type::make_error_type();
}
}
{
if (t->named_type() != NULL && t->points_to() != NULL)
{
- error_at(p->location(), "embedded type may not be a pointer");
+ go_error_at(p->location(), "embedded type may not be a pointer");
p->set_type(Type::make_error_type());
}
else if (t->points_to() != NULL
&& t->points_to()->interface_type() != NULL)
{
- error_at(p->location(),
+ go_error_at(p->location(),
"embedded type may not be pointer to interface");
p->set_type(Type::make_error_type());
}
if (!this->length_->is_constant())
{
- error_at(this->length_->location(), "array bound is not constant");
+ go_error_at(this->length_->location(), "array bound is not constant");
return false;
}
{
if (this->length_->type()->integer_type() != NULL
|| this->length_->type()->float_type() != NULL)
- error_at(this->length_->location(), "array bound is not constant");
+ go_error_at(this->length_->location(), "array bound is not constant");
else
- error_at(this->length_->location(), "array bound is not numeric");
+ go_error_at(this->length_->location(), "array bound is not numeric");
return false;
}
case Numeric_constant::NC_UL_VALID:
if (sizeof(val) >= tbits / 8 && val >> (tbits - 1) != 0)
{
- error_at(this->length_->location(), "array bound overflows");
+ go_error_at(this->length_->location(), "array bound overflows");
return false;
}
break;
case Numeric_constant::NC_UL_NOTINT:
- error_at(this->length_->location(), "array bound truncated to integer");
+ go_error_at(this->length_->location(), "array bound truncated to integer");
return false;
case Numeric_constant::NC_UL_NEGATIVE:
- error_at(this->length_->location(), "negative array bound");
+ go_error_at(this->length_->location(), "negative array bound");
return false;
case Numeric_constant::NC_UL_BIG:
{
mpz_clear(val);
if (bits >= tbits)
{
- error_at(this->length_->location(), "array bound overflows");
+ go_error_at(this->length_->location(), "array bound overflows");
return false;
}
}
{
// The runtime support uses "map[void]void".
if (!this->key_type_->is_comparable() && !this->key_type_->is_void_type())
- error_at(this->location_, "invalid map key type");
+ go_error_at(this->location_, "invalid map key type");
return true;
}
int64_t keysize;
if (!this->key_type_->backend_type_size(gogo, &keysize))
{
- error_at(this->location_, "error determining map key type size");
+ go_error_at(this->location_, "error determining map key type size");
return Expression::make_error(this->location_);
}
int64_t valsize;
if (!this->val_type_->backend_type_size(gogo, &valsize))
{
- error_at(this->location_, "error determining map value type size");
+ go_error_at(this->location_, "error determining map value type size");
return Expression::make_error(this->location_);
}
else if (this->find_method(p->name()) == NULL)
this->all_methods_->push_back(*p);
else
- error_at(p->location(), "duplicate method %qs",
+ go_error_at(p->location(), "duplicate method %qs",
Gogo::message_name(p->name()).c_str());
}
if (it == NULL)
{
if (!t->is_error())
- error_at(tl, "interface contains embedded non-interface");
+ go_error_at(tl, "interface contains embedded non-interface");
continue;
}
if (it == this)
{
if (!issued_recursive_error)
{
- error_at(tl, "invalid recursive interface");
+ go_error_at(tl, "invalid recursive interface");
issued_recursive_error = true;
}
continue;
{
if (*q == nt)
{
- error_at(tl, "inherited interface loop");
+ go_error_at(tl, "inherited interface loop");
break;
}
}
this->all_methods_->push_back(Typed_identifier(q->name(),
q->type(), tl));
else
- error_at(tl, "inherited method %qs is ambiguous",
+ go_error_at(tl, "inherited method %qs is ambiguous",
Gogo::message_name(q->name()).c_str());
}
}
char buf[200];
snprintf(buf, sizeof buf,
_("need explicit conversion; missing method %s%s%s"),
- open_quote, Gogo::message_name(p->name()).c_str(),
- close_quote);
+ go_open_quote(), Gogo::message_name(p->name()).c_str(),
+ go_close_quote());
reason->assign(buf);
}
return false;
char* buf = new char[len];
if (subreason.empty())
snprintf(buf, len, _("incompatible type for method %s%s%s"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
else
snprintf(buf, len,
_("incompatible type for method %s%s%s (%s)"),
- open_quote, n.c_str(), close_quote,
+ go_open_quote(), n.c_str(), go_close_quote(),
subreason.c_str());
reason->assign(buf);
delete[] buf;
char* buf = new char[len];
if (is_ambiguous)
snprintf(buf, len, _("ambiguous method %s%s%s"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
else
snprintf(buf, len, _("missing method %s%s%s"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
reason->assign(buf);
delete[] buf;
}
char* buf = new char[len];
if (subreason.empty())
snprintf(buf, len, _("incompatible type for method %s%s%s"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
else
snprintf(buf, len,
_("incompatible type for method %s%s%s (%s)"),
- open_quote, n.c_str(), close_quote,
+ go_open_quote(), n.c_str(), go_close_quote(),
subreason.c_str());
reason->assign(buf);
delete[] buf;
char* buf = new char[len];
snprintf(buf, len,
_("method %s%s%s requires a pointer receiver"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
reason->assign(buf);
delete[] buf;
}
char* buf = new char[len];
snprintf(buf, len,
_("method %s%s%s is marked go:nointerface"),
- open_quote, n.c_str(), close_quote);
+ go_open_quote(), n.c_str(), go_close_quote());
reason->assign(buf);
delete[] buf;
}
for (Bindings::const_declarations_iterator p = lm->begin_declarations();
p != lm->end_declarations();
++p)
- error_at(p->second->location(),
- "invalid pointer or interface receiver type");
+ go_error_at(p->second->location(),
+ "invalid pointer or interface receiver type");
delete this->local_methods_;
this->local_methods_ = NULL;
return;
Type::traverse(this->type_, &find);
if (find.found())
{
- error_at(this->location_, "invalid recursive type %qs",
- this->message_name().c_str());
+ go_error_at(this->location_, "invalid recursive type %qs",
+ this->message_name().c_str());
this->is_error_ = true;
return false;
}
const std::string& name(p->first);
if (st != NULL && st->find_local_field(name, NULL) != NULL)
{
- error_at(p->second->location(),
- "method %qs redeclares struct field name",
- Gogo::message_name(name).c_str());
+ go_error_at(p->second->location(),
+ "method %qs redeclares struct field name",
+ Gogo::message_name(name).c_str());
}
}
}
go_assert(m != NULL);
if (dereferenced)
{
- error_at(location,
- "calling method %qs requires explicit dereference",
- Gogo::message_name(name).c_str());
+ go_error_at(location,
+ "calling method %qs requires explicit dereference",
+ Gogo::message_name(name).c_str());
return Expression::make_error(location);
}
if (!m->is_value_method() && expr->type()->points_to() == NULL)
// An error was already reported.
}
else if (!ambig1.empty())
- error_at(location, "%qs is ambiguous via %qs and %qs",
- Gogo::message_name(name).c_str(), ambig1.c_str(),
- ambig2.c_str());
+ go_error_at(location, "%qs is ambiguous via %qs and %qs",
+ Gogo::message_name(name).c_str(), ambig1.c_str(),
+ ambig2.c_str());
else if (found_pointer_method)
- error_at(location, "method requires a pointer receiver");
+ go_error_at(location, "method requires a pointer receiver");
else if (nt == NULL && st == NULL && it == NULL)
- error_at(location,
- ("reference to field %qs in object which "
- "has no fields or methods"),
- Gogo::message_name(name).c_str());
+ go_error_at(location,
+ ("reference to field %qs in object which "
+ "has no fields or methods"),
+ Gogo::message_name(name).c_str());
else
{
bool is_unexported;
&seen);
}
if (is_unexported)
- error_at(location, "reference to unexported field or method %qs",
- Gogo::message_name(name).c_str());
+ go_error_at(location, "reference to unexported field or method %qs",
+ Gogo::message_name(name).c_str());
else
- error_at(location, "reference to undefined field or method %qs",
- Gogo::message_name(name).c_str());
+ go_error_at(location, "reference to undefined field or method %qs",
+ Gogo::message_name(name).c_str());
}
return Expression::make_error(location);
}
// The name was not defined anywhere.
if (!this->warned_)
{
- error_at(this->named_object_->location(),
- "use of undefined type %qs",
- no->message_name().c_str());
+ go_error_at(this->named_object_->location(),
+ "use of undefined type %qs",
+ no->message_name().c_str());
this->warned_ = true;
}
}
// The name was seen as a type, but the type was never defined.
if (no->type_declaration_value()->using_type())
{
- error_at(this->named_object_->location(),
- "use of undefined type %qs",
- no->message_name().c_str());
+ go_error_at(this->named_object_->location(),
+ "use of undefined type %qs",
+ no->message_name().c_str());
this->warned_ = true;
}
}
// The name was defined, but not as a type.
if (!this->warned_)
{
- error_at(this->named_object_->location(), "expected type");
+ go_error_at(this->named_object_->location(), "expected type");
this->warned_ = true;
}
}