]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/rust-gcc-diagnostics.cc
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
19 // rust-gcc-diagnostics.cc -- GCC implementation of rust diagnostics interface.
21 #include "rust-system.h"
22 #include "rust-diagnostics.h"
27 rust_be_internal_error_at (const Location location
, const std::string
&errmsg
)
29 std::string loc_str
= Linemap::location_to_string (location
);
31 internal_error ("%s", errmsg
.c_str ());
33 internal_error ("at %s, %s", loc_str
.c_str (), errmsg
.c_str ());
37 rust_be_error_at (const Location location
, const std::string
&errmsg
)
39 location_t gcc_loc
= location
.gcc_location ();
40 error_at (gcc_loc
, "%s", errmsg
.c_str ());
44 rust_be_warning_at (const Location location
, int opt
,
45 const std::string
&warningmsg
)
47 location_t gcc_loc
= location
.gcc_location ();
48 warning_at (gcc_loc
, opt
, "%s", warningmsg
.c_str ());
52 rust_be_fatal_error (const Location location
, const std::string
&fatalmsg
)
54 location_t gcc_loc
= location
.gcc_location ();
55 fatal_error (gcc_loc
, "%s", fatalmsg
.c_str ());
59 rust_be_inform (const Location location
, const std::string
&infomsg
)
61 location_t gcc_loc
= location
.gcc_location ();
62 inform (gcc_loc
, "%s", infomsg
.c_str ());
66 rust_be_error_at (const RichLocation
&location
, const std::string
&errmsg
)
68 /* TODO: 'error_at' would like a non-'const' 'rich_location *'. */
69 rich_location
&gcc_loc
= const_cast<rich_location
&> (location
.get ());
70 error_at (&gcc_loc
, "%s", errmsg
.c_str ());
74 rust_be_get_quotechars (const char **open_qu
, const char **close_qu
)
76 *open_qu
= open_quote
;
77 *close_qu
= close_quote
;
81 rust_be_debug_p (void)
83 return !!flag_rust_debug
;