aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-07-09 23:23:14 -0400
committerPhilip Herron <philip.herron@embecosm.com>2023-07-11 10:25:37 +0000
commit5d124d1512f93aec076a696daf15dcc646186383 (patch)
treee58e2bde2dc12758d76671ba45bccb988e87e1f7 /gcc
parent6ba9a11eae9a30c3f66e41f9ff8604f65e3ecc6f (diff)
downloadgcc-5d124d1512f93aec076a696daf15dcc646186383.zip
gcc-5d124d1512f93aec076a696daf15dcc646186383.tar.gz
gcc-5d124d1512f93aec076a696daf15dcc646186383.tar.bz2
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 4847f6f..11ca98c 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 782b34f..2030470 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,