From: LĂșcio Boari Fleury <[email protected]>

gcc/rust/ChangeLog:

        * parse/rust-parse-impl.h: Add early exit condition to parsing loop.

Signed-off-by: LĂșcio Boari Fleury <[email protected]>
---
 gcc/rust/parse/rust-parse-impl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 0421d6cb80e..afc70123095 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -1861,7 +1861,8 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi (
 
   t = lexer.peek_token ();
   // parse token trees until the initial delimiter token is found again
-  while (!token_id_matches_delims (t->get_id (), delim_type))
+  while (!token_id_matches_delims (t->get_id (), delim_type)
+        && t->get_id () != END_OF_FILE)
     {
       std::unique_ptr<AST::TokenTree> tree = parse_token_tree ();
 
-- 
2.50.1

Reply via email to