diff options
author | David Malcolm <dmalcolm@redhat.com> | 2023-09-07 11:33:39 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-09-07 11:37:40 +0200 |
commit | 1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3 (patch) | |
tree | 3a0edf68fbf8d07d0140d5280eeea4b25e4978a1 /gcc/rust/rust-diagnostics.h | |
parent | 1ad5ae5a45f2e3fc6948b35a3b052fdd48453704 (diff) | |
download | gcc-1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3.zip gcc-1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3.tar.gz gcc-1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3.tar.bz2 |
gccrs: Experiment with adding an error code to an error
gcc/rust/ChangeLog:
* rust-diagnostics.cc (rust_error_at): New overload.
* rust-diagnostics.h (struct ErrorCode): New struct.
(rust_error_at): New.
(rust_be_error_at): Likewise.
* rust-gcc-diagnostics.cc (class rust_error_code_rule): New class.
(rust_be_error_at): New function.
* typecheck/rust-casts.cc (TypeCastRules::emit_cast_error): Emit E0054
when reporting invalid cast error.
gcc/testsuite/ChangeLog:
* rust/compile/bad_as_bool_char.rs: Add error code to testcase.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/rust/rust-diagnostics.h')
-rw-r--r-- | gcc/rust/rust-diagnostics.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 43fee8b..d198bd5 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -50,6 +50,18 @@ // clang-format off // simple location + +struct ErrorCode +{ + explicit ErrorCode (const char *str) : m_str (str) + { + gcc_assert (str); + gcc_assert (str[0] == 'E'); + } + + const char *m_str; +}; + extern void rust_internal_error_at (const Location, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3) @@ -72,6 +84,9 @@ rust_inform (const Location, const char *fmt, ...) extern void rust_error_at (const RichLocation &, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); +extern void +rust_error_at (const RichLocation &, 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 @@ -97,6 +112,9 @@ rust_be_error_at (const Location, 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, + const std::string &errmsg); +extern void rust_be_warning_at (const Location, int opt, const std::string &warningmsg); extern void rust_be_fatal_error (const Location, const std::string &errmsg) |