Skip to content

Commit e77c44e

Browse files
dkmphilberty
authored andcommitted
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
1 parent fabb389 commit e77c44e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

gcc/rust/lex/rust-lex.cc

+8
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,14 @@ Lexer::build_token ()
427427
current_column++; // for error-handling
428428
current_char = peek_input ();
429429

430+
if (current_char == EOF)
431+
{
432+
rust_error_at (
433+
loc, "unexpected EOF while looking for end of comment",
434+
current_char);
435+
break;
436+
}
437+
430438
// if /* found
431439
if (current_char == '/' && peek_input (1) == '*')
432440
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This comment needs closure :) !

0 commit comments

Comments
 (0)