diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2021-03-23 22:03:55 +0100 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-27 18:07:49 +0000 |
commit | e77c44ef26fdf7e66fd7129a3aa9240840344694 (patch) | |
tree | e6f551284851657d57967a7d1583c058d8047780 | |
parent | fabb3894d5fe5c2ca87917fd08b2f0813553532d (diff) | |
download | gcc-e77c44ef26fdf7e66fd7129a3aa9240840344694.zip gcc-e77c44ef26fdf7e66fd7129a3aa9240840344694.tar.gz gcc-e77c44ef26fdf7e66fd7129a3aa9240840344694.tar.bz2 |
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
-rw-r--r-- | gcc/rust/lex/rust-lex.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/rust.test/fail_compilation/unterminated_c_comment.rs | 1 |
2 files changed, 9 insertions, 0 deletions
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) == '*') { diff --git a/gcc/testsuite/rust.test/fail_compilation/unterminated_c_comment.rs b/gcc/testsuite/rust.test/fail_compilation/unterminated_c_comment.rs new file mode 100644 index 0000000..4d04d01 --- /dev/null +++ b/gcc/testsuite/rust.test/fail_compilation/unterminated_c_comment.rs @@ -0,0 +1 @@ +/* This comment needs closure :) ! |