aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-11-04 16:04:04 -0400
committerRuss Cox <rsc@golang.org>2010-11-04 16:04:04 -0400
commit132e5435e389b01d305e842d7ae8c9f787fd4dc0 (patch)
treee477f0358cf2d8236e9933852b87233d71cd82ee
parent68b4255a9644a838898bfc6567bae97585c2e871 (diff)
downloadgo-132e5435e389b01d305e842d7ae8c9f787fd4dc0.tar.gz
go-132e5435e389b01d305e842d7ae8c9f787fd4dc0.zip
gc: line comments may end in EOF
R=ken2 CC=golang-dev https://golang.org/cl/2907041
-rw-r--r--src/cmd/gc/lex.c6
-rw-r--r--test/eof1.go9
2 files changed, 10 insertions, 5 deletions
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index f9d9267709..9dded356d4 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -728,14 +728,10 @@ l0:
if(c1 == '/') {
c = getlinepragma();
for(;;) {
- if(c == '\n') {
+ if(c == '\n' || c == EOF) {
ungetc(c);
goto l0;
}
- if(c == EOF) {
- yyerror("eof in comment");
- errorexit();
- }
c = getr();
}
}
diff --git a/test/eof1.go b/test/eof1.go
new file mode 100644
index 0000000000..c39a3cfdb1
--- /dev/null
+++ b/test/eof1.go
@@ -0,0 +1,9 @@
+// $G $D/$F.go
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// No newline at the end of this comment. \ No newline at end of file