From e77c44ef26fdf7e66fd7129a3aa9240840344694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Tue, 23 Mar 2021 22:03:55 +0100 Subject: Fix error while unexpected EOF when scanning for end of comment Emit an error when EOF is reached before end of C-style comment. Add corresponding test for non regression. fix #300 --- gcc/rust/lex/rust-lex.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/rust') diff --git a/gcc/rust/lex/rust-lex.cc b/gcc/rust/lex/rust-lex.cc index 6dfaea2..26745e4 100644 --- a/gcc/rust/lex/rust-lex.cc +++ b/gcc/rust/lex/rust-lex.cc @@ -427,6 +427,14 @@ Lexer::build_token () current_column++; // for error-handling current_char = peek_input (); + if (current_char == EOF) + { + rust_error_at ( + loc, "unexpected EOF while looking for end of comment", + current_char); + break; + } + // if /* found if (current_char == '/' && peek_input (1) == '*') { -- cgit v1.1