Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gcc/rust/rust-lang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ grs_langhook_init (void)

using_eh_for_cleanups ();

if (num_in_fnames == 0)
main_input_filename = "-";
Comment on lines +113 to +114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Is it how the other frontends handle that case?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In grs_langhook_init, I'm covering the case when the global variable num_in_fnames is zero before main_input_filename is used.

This is like a safety check if the grs_langhook_post_options didnt catch the error.


// initialise compiler session
Rust::Session::get_instance ().init ();

Expand Down Expand Up @@ -286,6 +289,10 @@ grs_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
{
// can be used to override other options if required

// check for input file
if (!*pfilename && num_in_fnames == 0)
*pfilename = "-";
Comment on lines +292 to +294
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In grs_langhook_post_options, I'm covering the case when no filename was passed in CLI and the filename pointer is null.


// satisfies an assert in init_excess_precision in toplev.cc
if (flag_excess_precision /*_cmdline*/ == EXCESS_PRECISION_DEFAULT)
flag_excess_precision /*_cmdline*/ = EXCESS_PRECISION_STANDARD;
Expand Down
6 changes: 6 additions & 0 deletions gcc/rust/rust-session-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ Session::enable_dump (std::string arg)
void
Session::handle_input_files (int num_files, const char **files)
{
if (num_files == 0)
{
static const char *stdin_file[] = {"-"};
files = stdin_file;
num_files = 1;
}
if (num_files != 1)
rust_fatal_error (UNDEF_LOCATION,
"only one file may be specified on the command line");
Expand Down
Loading