Skip to content

Commit

Permalink
A bit of 'RichLocation' C++ tuning [#247], [#97, #374]
Browse files Browse the repository at this point in the history
... in preparation for a merge from GCC upstream, where we otherwise run into
several different build errors.

Follow-up to commit ed651fc
"Add basic wrapper over gcc rich_location".
  • Loading branch information
tschwinge committed Sep 24, 2021
1 parent 4abf34c commit 4c386aa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gcc/rust/rust-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ rust_inform (const Location location, const char *fmt, ...)

// Rich Locations
void
rust_error_at (const RichLocation location, const char *fmt, ...)
rust_error_at (const RichLocation &location, const char *fmt, ...)
{
va_list ap;

Expand Down
4 changes: 2 additions & 2 deletions gcc/rust/rust-diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ rust_inform (const Location, const char *fmt, ...)

// rich locations
extern void
rust_error_at (const RichLocation, const char *fmt, ...)
rust_error_at (const RichLocation &, const char *fmt, ...)
RUST_ATTRIBUTE_GCC_DIAG (2, 3);

// These interfaces provide a way for the front end to ask for
Expand All @@ -84,7 +84,7 @@ rust_close_quote ();
extern void
rust_be_error_at (const Location, const std::string &errmsg);
extern void
rust_be_error_at (const RichLocation, const std::string &errmsg);
rust_be_error_at (const RichLocation &, const std::string &errmsg);
extern void
rust_be_warning_at (const Location, int opt, const std::string &warningmsg);
extern void
Expand Down
5 changes: 3 additions & 2 deletions gcc/rust/rust-gcc-diagnostics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ rust_be_inform (const Location location, const std::string &infomsg)
}

void
rust_be_error_at (const RichLocation location, const std::string &errmsg)
rust_be_error_at (const RichLocation &location, const std::string &errmsg)
{
rich_location gcc_loc = location.get ();
/* TODO: 'error_at' would like a non-'const' 'rich_location *'. */
rich_location &gcc_loc = const_cast<rich_location &> (location.get ());
error_at (&gcc_loc, "%s", errmsg.c_str ());
}

Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/rust-location.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class RichLocation

void add_fixit_insert_after (Location where, const std::string &new_parent);

rich_location get () const { return gcc_rich_loc; }
const rich_location &get () const { return gcc_rich_loc; }

private:
rich_location gcc_rich_loc;
Expand Down

0 comments on commit 4c386aa

Please sign in to comment.