mirror of
https://github.com/golang/go
synced 2024-11-21 19:14:44 -07:00
gc: fix line number at EOF
Fixes #1474. R=ken2 CC=golang-dev https://golang.org/cl/4432061
This commit is contained in:
parent
c7008f47ec
commit
7879d3118c
@ -582,6 +582,7 @@ struct Io
|
||||
Biobuf* bin;
|
||||
int32 ilineno;
|
||||
int nlsemi;
|
||||
int eofnl;
|
||||
int peekc;
|
||||
int peekc1; // second peekc for ...
|
||||
char* cp; // used for content when bin==nil
|
||||
|
@ -1310,7 +1310,7 @@ getc(void)
|
||||
lexlineno++;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
if(curio.bin == nil) {
|
||||
c = *curio.cp & 0xff;
|
||||
if(c != 0)
|
||||
@ -1325,8 +1325,11 @@ getc(void)
|
||||
break;
|
||||
}
|
||||
case EOF:
|
||||
return EOF;
|
||||
|
||||
// insert \n at EOF
|
||||
if(curio.eofnl)
|
||||
return EOF;
|
||||
curio.eofnl = 1;
|
||||
c = '\n';
|
||||
case '\n':
|
||||
if(pushedio.bin == nil)
|
||||
lexlineno++;
|
||||
|
17
test/fixedbugs/bug332.go
Normal file
17
test/fixedbugs/bug332.go
Normal file
@ -0,0 +1,17 @@
|
||||
// errchk $G $D/$F.go
|
||||
|
||||
// Copyright 2011 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
|
||||
|
||||
// type T int
|
||||
|
||||
func main() {}
|
||||
|
||||
// issue 1474
|
||||
|
||||
// important: no newline on end of next line.
|
||||
// 6g used to print <epoch> instead of bug332.go:111
|
||||
func (t *T) F() {} // ERROR "bug332"
|
Loading…
Reference in New Issue
Block a user