summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/align.c7
-rw-r--r--src/cmd/gc/go.h1
-rw-r--r--src/cmd/gc/go.y10
-rw-r--r--src/cmd/gc/lex.c1
-rw-r--r--src/cmd/gc/subr.c1
-rw-r--r--src/cmd/godoc/godoc.go6
-rw-r--r--test/golden.out12
7 files changed, 20 insertions, 18 deletions
diff --git a/src/cmd/gc/align.c b/src/cmd/gc/align.c
index 34f3e9c84..81ea9a7fe 100644
--- a/src/cmd/gc/align.c
+++ b/src/cmd/gc/align.c
@@ -97,6 +97,7 @@ dowidth(Type *t)
{
int32 et;
uint32 w;
+ int lno;
if(maxround == 0 || widthptr == 0)
fatal("dowidth without betypeinit");
@@ -108,11 +109,16 @@ dowidth(Type *t)
return;
if(t->width == -2) {
+ lno = lineno;
+ lineno = t->lineno;
yyerror("invalid recursive type %T", t);
t->width = 0;
+ lineno = lno;
return;
}
+ lno = lineno;
+ lineno = t->lineno;
t->width = -2;
et = t->etype;
@@ -218,6 +224,7 @@ dowidth(Type *t)
}
t->width = w;
+ lineno = lno;
}
void
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h
index b4fcd4bef..d709c3974 100644
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -143,6 +143,7 @@ struct Type
uchar deferwidth;
Node* nod; // canonical OTYPE node
+ int lineno;
// TFUNCT
uchar thistuple;
diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y
index 129e77d6d..dfee62293 100644
--- a/src/cmd/gc/go.y
+++ b/src/cmd/gc/go.y
@@ -177,14 +177,6 @@ import_stmt:
break;
}
- // In order to allow multifile packages to use type names
- // that are the same as the package name (i.e. go/parser
- // is package parser and has a type called parser), we have
- // to not bother trying to declare the package if it is our package.
- // TODO(rsc): Is there a better way to tell if the package is ours?
- if(my == import && strcmp(import->name, package) == 0)
- break;
-
// TODO(rsc): this line is needed for a package
// which does bytes := in a function, which creates
// an ONONAME for bytes, but then a different file
@@ -197,7 +189,7 @@ import_stmt:
my->def = nod(OPACK, N, N);
my->def->sym = import;
my->lastlineno = $1;
- import->block = -1; // above top level
+ import->block = 1; // at top level
}
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index 7e9e8d5b3..f9ce1a148 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -447,6 +447,7 @@ l0:
switch(c) {
case EOF:
+ lineno = prevlineno;
ungetc(EOF);
return -1;
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index 7a7259ca3..d4e62e6f9 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -392,6 +392,7 @@ typ(int et)
t = mal(sizeof(*t));
t->etype = et;
t->width = BADWIDTH;
+ t->lineno = lineno;
return t;
}
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index f7ba3dbbe..34b03aaae 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -567,7 +567,7 @@ func exec(c *http.Conn, args []string) bool {
}
-func sync(c *http.Conn, r *http.Request) {
+func dosync(c *http.Conn, r *http.Request) {
args := []string{"/bin/sh", "-c", *syncCmd};
if !exec(c, args) {
*syncMin = 0; // disable sync
@@ -622,7 +622,7 @@ func main() {
http.Handle(Pkg, http.HandlerFunc(servePkg));
if *syncCmd != "" {
- http.Handle("/debug/sync", http.HandlerFunc(sync));
+ http.Handle("/debug/sync", http.HandlerFunc(dosync));
}
http.Handle("/", http.HandlerFunc(serveFile));
@@ -638,7 +638,7 @@ func main() {
log.Stderrf("sync every %dmin", *syncMin);
}
for *syncMin > 0 {
- sync(nil, nil);
+ dosync(nil, nil);
time.Sleep(int64(*syncMin) * (60 * 1e9));
}
if *verbose {
diff --git a/test/golden.out b/test/golden.out
index f3841b15b..1c4981b35 100644
--- a/test/golden.out
+++ b/test/golden.out
@@ -161,10 +161,10 @@ BUG: 0 1
BUG: errchk: command succeeded unexpectedly
=========== bugs/bug190.go
-<epoch>: invalid recursive type []S
-<epoch>: invalid recursive type S
-<epoch>: invalid recursive type S
-<epoch>: invalid recursive type chan S
-<epoch>: invalid recursive type S
-<epoch>: invalid recursive type func(S) (S)
+bugs/bug190.go:11: invalid recursive type []S
+bugs/bug190.go:16: invalid recursive type S
+bugs/bug190.go:16: invalid recursive type S
+bugs/bug190.go:13: invalid recursive type chan S
+bugs/bug190.go:16: invalid recursive type S
+bugs/bug190.go:15: invalid recursive type func(S) (S)
BUG: should compile