Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions gcc/rust/rust-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,28 @@ rust_error_at (const rich_location &location, const ErrorCode code,
va_end (ap);
}

void
rust_be_error_at (rich_location *richloc, const ErrorCode code,
const std::string &errmsg)
{
diagnostic_metadata m;
rust_error_code_rule rule (code);
m.add_rule (rule);
error_meta (richloc, m, "%s", errmsg.c_str ());
}

void
rust_error_at (rich_location *richloc, const ErrorCode code, const char *fmt,
...)
{
/* TODO: Refactoring diagnostics to this overload */
va_list ap;

va_start (ap, fmt);
rust_be_error_at (richloc, code, expand_message (fmt, ap));
va_end (ap);
}

void
rust_be_warning_at (const location_t location, int opt,
const std::string &warningmsg)
Expand Down Expand Up @@ -345,6 +367,23 @@ rust_error_at (const rich_location &location, const char *fmt, ...)
va_end (ap);
}

void
rust_be_error_at (rich_location *richloc, const std::string &errmsg)
{
error_at (richloc, "%s", errmsg.c_str ());
}

void
rust_error_at (rich_location *richloc, const char *fmt, ...)
{
/* TODO: Refactoring diagnostics to this overload */
va_list ap;

va_start (ap, fmt);
rust_be_error_at (richloc, expand_message (fmt, ap));
va_end (ap);
}

bool
rust_be_debug_p (void)
{
Expand Down
11 changes: 11 additions & 0 deletions gcc/rust/rust-diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ rust_error_at (const rich_location &, const char *fmt, ...)
extern void
rust_error_at (const rich_location &, const ErrorCode, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (3, 4);
extern void /* similiar to other frontends */
rust_error_at(rich_location *richloc,const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
extern void /* similiar to other frontends */
rust_error_at(rich_location *richloc, const ErrorCode, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (3, 4);
// clang-format on

// These interfaces provide a way for the front end to ask for
Expand Down Expand Up @@ -137,6 +143,11 @@ rust_be_error_at (const rich_location &, const std::string &errmsg);
extern void
rust_be_error_at (const rich_location &, const ErrorCode,
const std::string &errmsg);
extern void /* similiar to other frontends */
rust_be_error_at (rich_location *richloc, const std::string &errmsg);
extern void /* similiar to other frontends */
rust_be_error_at (rich_location *richloc, const ErrorCode,
const std::string &errmsg);
extern void
rust_be_warning_at (const location_t, int opt, const std::string &warningmsg);
extern void
Expand Down
18 changes: 18 additions & 0 deletions gcc/rust/rust_error_codes.def
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// Copyright (C) 2020-2023 Free Software Foundation, Inc.

// 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/>.

ERROR(0001), // this error code is no longer emitted by the compiler
ERROR(0002), // this error code is no longer emitted by the compiler
ERROR(0004),
Expand Down