]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/rust-gcc-diagnostics.cc
Update copyright years.
[thirdparty/gcc.git] / gcc / rust / rust-gcc-diagnostics.cc
1 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
2
3 // This file is part of GCC.
4
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
8 // version.
9
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
13 // for more details.
14
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/>.
18
19 // rust-gcc-diagnostics.cc -- GCC implementation of rust diagnostics interface.
20
21 #include "rust-system.h"
22 #include "rust-diagnostics.h"
23
24 #include "options.h"
25
26 void
27 rust_be_internal_error_at (const Location location, const std::string &errmsg)
28 {
29 std::string loc_str = Linemap::location_to_string (location);
30 if (loc_str.empty ())
31 internal_error ("%s", errmsg.c_str ());
32 else
33 internal_error ("at %s, %s", loc_str.c_str (), errmsg.c_str ());
34 }
35
36 void
37 rust_be_error_at (const Location location, const std::string &errmsg)
38 {
39 location_t gcc_loc = location.gcc_location ();
40 error_at (gcc_loc, "%s", errmsg.c_str ());
41 }
42
43 void
44 rust_be_warning_at (const Location location, int opt,
45 const std::string &warningmsg)
46 {
47 location_t gcc_loc = location.gcc_location ();
48 warning_at (gcc_loc, opt, "%s", warningmsg.c_str ());
49 }
50
51 void
52 rust_be_fatal_error (const Location location, const std::string &fatalmsg)
53 {
54 location_t gcc_loc = location.gcc_location ();
55 fatal_error (gcc_loc, "%s", fatalmsg.c_str ());
56 }
57
58 void
59 rust_be_inform (const Location location, const std::string &infomsg)
60 {
61 location_t gcc_loc = location.gcc_location ();
62 inform (gcc_loc, "%s", infomsg.c_str ());
63 }
64
65 void
66 rust_be_error_at (const RichLocation &location, const std::string &errmsg)
67 {
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 ());
71 }
72
73 void
74 rust_be_get_quotechars (const char **open_qu, const char **close_qu)
75 {
76 *open_qu = open_quote;
77 *close_qu = close_quote;
78 }
79
80 bool
81 rust_be_debug_p (void)
82 {
83 return !!flag_rust_debug;
84 }