diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2021-10-28 22:25:10 +0200 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-11-05 16:34:22 +0000 |
commit | 228240f32114fbbc17b73b1e91f245177c5aacc7 (patch) | |
tree | 7e485477949edd04278eea2bf097648bc4e9a2be /gcc | |
parent | e73922ef9f07c511c383cc37532d0324a1138d99 (diff) | |
download | gcc-228240f32114fbbc17b73b1e91f245177c5aacc7.zip gcc-228240f32114fbbc17b73b1e91f245177c5aacc7.tar.gz gcc-228240f32114fbbc17b73b1e91f245177c5aacc7.tar.bz2 |
Add 'rust_internal_error_at'
... corresponding to GCC's 'internal_error'.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/rust-diagnostics.cc | 10 | ||||
-rw-r--r-- | gcc/rust/rust-diagnostics.h | 7 | ||||
-rw-r--r-- | gcc/rust/rust-gcc-diagnostics.cc | 10 | ||||
-rw-r--r-- | gcc/rust/rust-system.h | 2 |
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index a82cac4..9982fa2 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -147,6 +147,16 @@ rust_close_quote () } void +rust_internal_error_at (const Location location, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + rust_be_internal_error_at (location, expand_message (fmt, ap)); + va_end (ap); +} + +void rust_error_at (const Location location, const char *fmt, ...) { va_list ap; diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index 93f8738..7fc0e69 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -50,6 +50,10 @@ // simple location extern void +rust_internal_error_at (const Location, const char *fmt, ...) + RUST_ATTRIBUTE_GCC_DIAG (2, 3) + RUST_ATTRIBUTE_NORETURN; +extern void rust_error_at (const Location, const char *fmt, ...) RUST_ATTRIBUTE_GCC_DIAG (2, 3); extern void @@ -82,6 +86,9 @@ rust_close_quote (); // implement these routines. extern void +rust_be_internal_error_at (const Location, const std::string &errmsg) + RUST_ATTRIBUTE_NORETURN; +extern void rust_be_error_at (const Location, const std::string &errmsg); extern void rust_be_error_at (const RichLocation &, const std::string &errmsg); diff --git a/gcc/rust/rust-gcc-diagnostics.cc b/gcc/rust/rust-gcc-diagnostics.cc index db6372e..7106dd4 100644 --- a/gcc/rust/rust-gcc-diagnostics.cc +++ b/gcc/rust/rust-gcc-diagnostics.cc @@ -24,6 +24,16 @@ #include "options.h" void +rust_be_internal_error_at (const Location location, const std::string &errmsg) +{ + std::string loc_str = Linemap::location_to_string (location); + if (loc_str.empty ()) + internal_error ("%s", errmsg.c_str ()); + else + internal_error ("at %s, %s", loc_str.c_str (), errmsg.c_str ()); +} + +void rust_be_error_at (const Location location, const std::string &errmsg) { location_t gcc_loc = location.gcc_location (); diff --git a/gcc/rust/rust-system.h b/gcc/rust/rust-system.h index e47fbdc..fa690d7 100644 --- a/gcc/rust/rust-system.h +++ b/gcc/rust/rust-system.h @@ -59,6 +59,8 @@ #include "diagnostic-core.h" /* For error_at and friends. */ #include "intl.h" /* For _(). */ +#define RUST_ATTRIBUTE_NORETURN ATTRIBUTE_NORETURN + // File separator to use based on whether or not the OS we're working with is // DOS-based #if defined(HAVE_DOS_BASED_FILE_SYSTEM) |