diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2021-06-03 23:57:34 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2021-06-04 09:48:30 +0200 |
commit | 4e43d678e2d9e8a0a155b33aeebb87d847527ac9 (patch) | |
tree | 80cab08459e22566c1e75bf23a4e33e3f988de8f /gcc | |
parent | ff4715d79e2c17d270db8b94315aa6b574f48994 (diff) | |
download | gcc-4e43d678e2d9e8a0a155b33aeebb87d847527ac9.zip gcc-4e43d678e2d9e8a0a155b33aeebb87d847527ac9.tar.gz gcc-4e43d678e2d9e8a0a155b33aeebb87d847527ac9.tar.bz2 |
Use '-frust-debug' to control dumping of various Rust front end internals
... as discussed in #479, and elsewhere.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/lang.opt | 4 | ||||
-rw-r--r-- | gcc/rust/rust-diagnostics.cc | 3 | ||||
-rw-r--r-- | gcc/rust/rust-diagnostics.h | 2 | ||||
-rw-r--r-- | gcc/rust/rust-gcc-diagnostics.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/debug-diagnostics-default.rs | 5 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/debug-diagnostics-off.rs | 7 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/debug-diagnostics-on.rs (renamed from gcc/testsuite/rust/compile/debug-diagnostics.rs) | 4 |
7 files changed, 32 insertions, 1 deletions
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index 4757dfb..707feeb 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -35,6 +35,10 @@ L Rust Joined Separate ; Not documented +frust-debug +Rust Var(flag_rust_debug) +Dump various Rust front end internals. + frust-dump- Rust Joined RejectNegative -frust-dump-<type> Dump Rust frontend internal information. diff --git a/gcc/rust/rust-diagnostics.cc b/gcc/rust/rust-diagnostics.cc index 27ce54e..6f405c9 100644 --- a/gcc/rust/rust-diagnostics.cc +++ b/gcc/rust/rust-diagnostics.cc @@ -200,6 +200,9 @@ rust_error_at (const RichLocation location, const char *fmt, ...) void rust_debug (const Location location, const char *fmt, ...) { + if (!rust_be_debug_p ()) + return; + va_list ap; va_start (ap, fmt); diff --git a/gcc/rust/rust-diagnostics.h b/gcc/rust/rust-diagnostics.h index cd9b13e..6c179f9 100644 --- a/gcc/rust/rust-diagnostics.h +++ b/gcc/rust/rust-diagnostics.h @@ -93,6 +93,8 @@ extern void rust_be_inform (const Location, const std::string &infomsg); extern void rust_be_get_quotechars (const char **open_quote, const char **close_quote); +extern bool +rust_be_debug_p (void); namespace Rust { /* A structure used to represent an error. Useful for enabling diff --git a/gcc/rust/rust-gcc-diagnostics.cc b/gcc/rust/rust-gcc-diagnostics.cc index 11da6a3..de8acc8 100644 --- a/gcc/rust/rust-gcc-diagnostics.cc +++ b/gcc/rust/rust-gcc-diagnostics.cc @@ -21,6 +21,8 @@ #include "rust-system.h" #include "rust-diagnostics.h" +#include "options.h" + void rust_be_error_at (const Location location, const std::string &errmsg) { @@ -63,3 +65,9 @@ rust_be_get_quotechars (const char **open_qu, const char **close_qu) *open_qu = open_quote; *close_qu = close_quote; } + +bool +rust_be_debug_p (void) +{ + return !!flag_rust_debug; +} diff --git a/gcc/testsuite/rust/compile/debug-diagnostics-default.rs b/gcc/testsuite/rust/compile/debug-diagnostics-default.rs new file mode 100644 index 0000000..90b0e57 --- /dev/null +++ b/gcc/testsuite/rust/compile/debug-diagnostics-default.rs @@ -0,0 +1,5 @@ +// Make sure we don't see any 'note's: +// { dg-bogus {note: } "" { target *-*-* } 0 } + +fn main() { +} diff --git a/gcc/testsuite/rust/compile/debug-diagnostics-off.rs b/gcc/testsuite/rust/compile/debug-diagnostics-off.rs new file mode 100644 index 0000000..77b82b3 --- /dev/null +++ b/gcc/testsuite/rust/compile/debug-diagnostics-off.rs @@ -0,0 +1,7 @@ +// { dg-additional-options "-fno-rust-debug" } + +// Make sure we don't see any 'note's: +// { dg-bogus {note: } "" { target *-*-* } 0 } + +fn main() { +} diff --git a/gcc/testsuite/rust/compile/debug-diagnostics.rs b/gcc/testsuite/rust/compile/debug-diagnostics-on.rs index 2966d9c..847fd24 100644 --- a/gcc/testsuite/rust/compile/debug-diagnostics.rs +++ b/gcc/testsuite/rust/compile/debug-diagnostics-on.rs @@ -1,5 +1,7 @@ +// { dg-additional-options "-frust-debug" } + // Just scan for one of the Rust front end debug diagnostics: -// { dg-message {note: Attempting to parse file: .+/gcc/testsuite/rust/compile/debug-diagnostics\.rs} "" { target *-*-* } 0 } +// { dg-message {note: Attempting to parse file: .+/gcc/testsuite/rust/compile/debug-diagnostics-on\.rs} "" { target *-*-* } 0 } fn main() { } |