diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-07-28 16:53:50 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-07-28 17:29:28 +0200 |
commit | 0ec8f938272b6dce9e133f98a199fd5123aa553f (patch) | |
tree | 3fe6f1997b4975e3e374298b070ac47ea7481c6c /gcc | |
parent | 237be3f618dfae396944c601c295eb182d32e54e (diff) | |
download | gcc-0ec8f938272b6dce9e133f98a199fd5123aa553f.zip gcc-0ec8f938272b6dce9e133f98a199fd5123aa553f.tar.gz gcc-0ec8f938272b6dce9e133f98a199fd5123aa553f.tar.bz2 |
session-manager: Produce a fatal error if multiple files are specified
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/rust-lang.cc | 36 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 23 | ||||
-rw-r--r-- | gcc/rust/rust-session-manager.h | 4 |
3 files changed, 15 insertions, 48 deletions
diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index dd8c608..95c92f8 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -69,13 +69,11 @@ // Language-dependent contents of a type. GTY() mark used for garbage collector. struct GTY (()) lang_type { - char dummy; }; // Language-dependent contents of a decl. struct GTY (()) lang_decl { - char dummy; }; // Language-dependent contents of an identifier. This must include a @@ -100,7 +98,6 @@ union GTY (( // We don't use language_function. struct GTY (()) language_function { - int dummy; }; // has to be in same compilation unit as session, so here for now @@ -172,7 +169,7 @@ grs_langhook_parse_file (void) { rust_debug ("Preparing to parse files. "); - Rust::Session::get_instance ().parse_files (num_in_fnames, in_fnames); + Rust::Session::get_instance ().handle_input_files (num_in_fnames, in_fnames); } /* Seems to get the exact type for a specific type - e.g. for scalar float with @@ -280,32 +277,10 @@ grs_langhook_handle_option ( { // Convert integer code to lang.opt enum codes with names. enum opt_code code = (enum opt_code) scode; - // used to store whether results of various stuff are successful - // bool ret = true; - // delegate to session manager + // Delegate to session manager return Rust::Session::get_instance ().handle_option (code, arg, value, kind, loc, handlers); - - // Handles options as listed in lang.opt. - /*switch (code) { - case OPT_I: - // TODO: add search path - break; - case OPT_L: - // TODO: add library link path or something - break; - case OPT_frust_dump: - // enable dump and return whether this was successful - ret = rust_enable_dump(arg) ? true : false; - break; - // no option handling for -o - default: - // return 1 to indicate option is valid - break; - } - - return ret;*/ } /* Run after parsing options. */ @@ -447,17 +422,10 @@ rust_localize_identifier (const char *ident) namespace selftest { -static void -simple_assert () -{ - ASSERT_TRUE (true); -} - void run_rust_tests () { // Call tests for the rust frontend here - simple_assert (); rust_cfg_parser_test (); rust_privacy_ctx_test (); rust_crate_name_validation_test (); diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 6a2c1b6..a7317247 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -574,13 +574,16 @@ Session::enable_dump (std::string arg) /* Actual main entry point for front-end. Called from langhook to parse files. */ void -Session::parse_files (int num_files, const char **files) +Session::handle_input_files (int num_files, const char **files) { + if (num_files != 1) + rust_fatal_error (Location (), + "only one file may be specified on the command line"); + + const auto &file = files[0]; + if (options.crate_name.empty ()) { - /* HACK: We use the first file to infer the crate name, which might be - * incorrect: since rustc only allows one file to be supplied in the - * command-line */ auto filename = "-"; if (num_files > 0) filename = files[0]; @@ -594,13 +597,9 @@ Session::parse_files (int num_files, const char **files) CrateNum crate_num = mappings->get_next_crate_num (options.get_crate_name ()); mappings->set_current_crate (crate_num); - for (int i = 0; i < num_files; i++) - { - rust_debug ("Attempting to parse file: %s", files[i]); - parse_file (files[i]); - } - /* TODO: should semantic analysis be dealed with here? or per file? for now, - * per-file. */ + + rust_debug ("Attempting to parse file: %s", file); + compile_crate (file); } void @@ -656,7 +655,7 @@ Session::handle_crate_name (const AST::Crate &parsed_crate) // Parses a single file with filename filename. void -Session::parse_file (const char *filename) +Session::compile_crate (const char *filename) { RAIIFile file_wrap (filename); if (!file_wrap.ok ()) diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h index 24a15f5..2432de7 100644 --- a/gcc/rust/rust-session-manager.h +++ b/gcc/rust/rust-session-manager.h @@ -298,7 +298,7 @@ public: bool handle_option (enum opt_code code, const char *arg, HOST_WIDE_INT value, int kind, location_t loc, const struct cl_option_handlers *handlers); - void parse_files (int num_files, const char **files); + void handle_input_files (int num_files, const char **files); void init_options (); void handle_crate_name (const AST::Crate &parsed_crate); @@ -314,7 +314,7 @@ public: NodeId load_extern_crate (const std::string &crate_name, Location locus); private: - void parse_file (const char *filename); + void compile_crate (const char *filename); bool enable_dump (std::string arg); void dump_lex (Parser<Lexer> &parser) const; |