From: Wesley Lewis <[email protected]>
Fixes Rust-GCC/gccrs#4937
gcc/rust/ChangeLog:
* parse/rust-parse-impl-macro.hxx
(Parser<ManagedTokenSource>::parse_macro_invocation_semi): Added error.
gcc/testsuite/ChangeLog:
* rust/compile/just_dollar.rs: New test.
Signed-off-by: Wesley Lewis <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/1bef66052c5ad9ecea86a540bd3766083c5b0e71
The commit has been mentioned in the following issue(s):
- Rust-GCC/gccrs#4937: https://github.com/Rust-GCC/gccrs/issues/4937
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/5000
gcc/rust/parse/rust-parse-impl-macro.hxx | 6 +++++-
gcc/testsuite/rust/compile/just_dollar.rs | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/rust/compile/just_dollar.rs
diff --git a/gcc/rust/parse/rust-parse-impl-macro.hxx
b/gcc/rust/parse/rust-parse-impl-macro.hxx
index 9f168bfdc..4f3c3b7de 100644
--- a/gcc/rust/parse/rust-parse-impl-macro.hxx
+++ b/gcc/rust/parse/rust-parse-impl-macro.hxx
@@ -33,7 +33,11 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi (
location_t macro_locus = lexer.peek_token ()->get_locus ();
auto path = parse_simple_path ();
if (!path)
- return nullptr;
+ {
+ rust_error_at (lexer.peek_token ()->get_locus (),
+ "failed to parse macro invocation path");
+ return nullptr;
+ }
if (!skip_token (EXCLAM))
{
diff --git a/gcc/testsuite/rust/compile/just_dollar.rs
b/gcc/testsuite/rust/compile/just_dollar.rs
new file mode 100644
index 000000000..424fb511f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/just_dollar.rs
@@ -0,0 +1 @@
+$ // { dg-error "failed to parse macro invocation path" "" { target *-*-* } }
\ No newline at end of file
base-commit: 7564074c39eba65fc3bba0dcc91854f7be4d971a
--
2.56.0