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]>

Tested on x86_64-pc-linux-gnu.

---
 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 9f168bfdcfc..4f3c3b7de56 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 00000000000..424fb511f6f
--- /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
-- 
2.55.0

Reply via email to