diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-11 22:45:32 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-08-11 22:45:32 +0000 |
commit | 5d44e40bb5ddc05b604a02e1b4f56ced179ac95b (patch) | |
tree | a24af8ccbfaeeeb01a92f6f7b3154cfa428eebc4 /gcc/go/gofrontend/lex.cc | |
parent | 63ab94b6d5d732161780c68fce775bd23f8e2a99 (diff) | |
download | gcc-5d44e40bb5ddc05b604a02e1b4f56ced179ac95b.zip gcc-5d44e40bb5ddc05b604a02e1b4f56ced179ac95b.tar.gz gcc-5d44e40bb5ddc05b604a02e1b4f56ced179ac95b.tar.bz2 |
compiler: Handle newlines in general comments.
On comments, the specification says
(http://golang.org/ref/spec#Comments): General comments start with the
character sequence /* and continue through the character sequence */.
A general comment containing one or more newlines acts like a newline,
otherwise it acts like a space.
Fixes golang/go#11528.
Reviewed-on: https://go-review.googlesource.com/13064
From-SVN: r226794
Diffstat (limited to 'gcc/go/gofrontend/lex.cc')
-rw-r--r-- | gcc/go/gofrontend/lex.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index 1d9085f..8de94c5 100644 --- a/gcc/go/gofrontend/lex.cc +++ b/gcc/go/gofrontend/lex.cc @@ -600,8 +600,14 @@ Lex::next_token() { this->lineoff_ = p + 2 - this->linebuf_; Location location = this->location(); - if (!this->skip_c_comment()) + bool found_newline = false; + if (!this->skip_c_comment(&found_newline)) return Token::make_invalid_token(location); + if (found_newline && this->add_semi_at_eol_) + { + this->add_semi_at_eol_ = false; + return this->make_operator(OPERATOR_SEMICOLON, 1); + } p = this->linebuf_ + this->lineoff_; pend = this->linebuf_ + this->linesize_; } @@ -1621,7 +1627,7 @@ Lex::one_character_operator(char c) // Skip a C-style comment. bool -Lex::skip_c_comment() +Lex::skip_c_comment(bool* found_newline) { while (true) { @@ -1642,6 +1648,9 @@ Lex::skip_c_comment() return true; } + if (p[0] == '\n') + *found_newline = true; + this->lineoff_ = p - this->linebuf_; unsigned int c; bool issued_error; |