diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-17 11:40:42 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-17 13:29:38 +0100 |
commit | e30d07de5c89e0f8a4d8304846e21f8e775c9f79 (patch) | |
tree | b55340fd2dffcb1f21940cf049b11abfd3d77c8b /gcc | |
parent | 2dfc19647774cb26a0f735bda8006068a40cfba0 (diff) | |
download | gcc-e30d07de5c89e0f8a4d8304846e21f8e775c9f79.zip gcc-e30d07de5c89e0f8a4d8304846e21f8e775c9f79.tar.gz gcc-e30d07de5c89e0f8a4d8304846e21f8e775c9f79.tar.bz2 |
parser: Handle -fsyntax-only properly
Handle the -fsyntax-only properly from the rust frontend. This flag
allows checking for syntax and stopping after that, skipping further
passes of the pipeline.
The flag was accepted by the frontend, but was not used anywhere.
Co-authored-by: philberty <philip.herron@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/rust-session-manager.cc | 5 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/syntax-only.rs | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc index 396f35f..96d94b2 100644 --- a/gcc/rust/rust-session-manager.cc +++ b/gcc/rust/rust-session-manager.cc @@ -542,6 +542,11 @@ Session::parse_file (const char *filename) rust_debug ("\033[0;31mSUCCESSFULLY PARSED CRATE \033[0m"); + // If -fsyntax-only was passed, we can just skip the remaining passes. + // Parsing errors are already emitted in `parse_crate()` + if (flag_syntax_only) + return; + // register plugins pipeline stage register_plugins (parsed_crate); rust_debug ("\033[0;31mSUCCESSFULLY REGISTERED PLUGINS \033[0m"); diff --git a/gcc/testsuite/rust/compile/syntax-only.rs b/gcc/testsuite/rust/compile/syntax-only.rs new file mode 100644 index 0000000..cd84907b --- /dev/null +++ b/gcc/testsuite/rust/compile/syntax-only.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-fsyntax-only" } + +fn main() { + let mut a = 15; + a = true; +} |