aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-09 23:23:14 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:49:35 +0100
commitf9b0ca04c88bcea93d9e80f2c98089da7484f0d7 (patch)
treeb2668476d6aef0eada37cfde07bdb2fd50e36ea4 /gcc
parent7b6c52cf4ef53d4f4816cbcd7e086daa1c872d29 (diff)
downloadgcc-f9b0ca04c88bcea93d9e80f2c98089da7484f0d7.zip
gcc-f9b0ca04c88bcea93d9e80f2c98089da7484f0d7.tar.gz
gcc-f9b0ca04c88bcea93d9e80f2c98089da7484f0d7.tar.bz2
gccrs: Add rust_error_at accepting location_t and ErrorCode
gcc/rust/ChangeLog: * rust-diagnostics.cc (rust_be_error_at): Add function accepting location_t and ErrorCode. (rust_error_at): Likewise. * rust-diagnostics.h (rust_error_at): Likewise. (rust_be_error_at): Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/rust-diagnostics.cc22
-rw-r--r--gcc/rust/rust-diagnostics.h6
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc
index 6c74546..113a128 100644
--- a/gcc/rust/rust-diagnostics.cc
+++ b/gcc/rust/rust-diagnostics.cc
@@ -213,6 +213,28 @@ private:
};
void
+rust_be_error_at (const Location location, const ErrorCode code,
+ const std::string &errmsg)
+{
+ rich_location gcc_loc (line_table, location);
+ diagnostic_metadata m;
+ rust_error_code_rule rule (code);
+ m.add_rule (rule);
+ error_meta (&gcc_loc, m, "%s", errmsg.c_str ());
+}
+
+void
+rust_error_at (const Location location, const ErrorCode code, const char *fmt,
+ ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ rust_be_error_at (location, code, expand_message (fmt, ap));
+ va_end (ap);
+}
+
+void
rust_be_error_at (const RichLocation &location, const ErrorCode code,
const std::string &errmsg)
{
diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h
index 58b1361..50097ef 100644
--- a/gcc/rust/rust-diagnostics.h
+++ b/gcc/rust/rust-diagnostics.h
@@ -70,6 +70,9 @@ extern void
rust_error_at (const Location, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);
extern void
+rust_error_at (const Location, const ErrorCode, const char *fmt, ...)
+ RUST_ATTRIBUTE_GCC_DIAG (3, 4);
+extern void
rust_warning_at (const Location, int opt, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (3, 4);
extern void
@@ -110,6 +113,9 @@ rust_be_internal_error_at (const Location, const std::string &errmsg)
extern void
rust_be_error_at (const Location, const std::string &errmsg);
extern void
+rust_be_error_at (const Location, const ErrorCode,
+ const std::string &errmsg);
+extern void
rust_be_error_at (const RichLocation &, const std::string &errmsg);
extern void
rust_be_error_at (const RichLocation &, const ErrorCode,