]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add rust_error_at accepting location_t and ErrorCode
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 10 Jul 2023 03:23:14 +0000 (23:23 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:49:35 +0000 (18:49 +0100)
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>
gcc/rust/rust-diagnostics.cc
gcc/rust/rust-diagnostics.h

index 6c745460e1611b755b8398742dfedf686812aeb1..113a128a3866facf98fdb0b0dc0a5cb84f2ad65b 100644 (file)
@@ -212,6 +212,28 @@ private:
   const ErrorCode m_code;
 };
 
+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)
index 58b13616480db63585259cde596f24c850203ea4..50097ef4ef891763d2bd7a54106c990cf1ed5dbc 100644 (file)
@@ -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,