mirror of
https://github.com/golang/go
synced 2024-11-22 05:44:41 -07:00
add & fix bug208, from ken.
fix bug198. R=ken OCL=35504 CL=35507
This commit is contained in:
parent
98fff8ffb2
commit
680ee6af63
@ -781,6 +781,10 @@ stotype(NodeList *l, int et, Type **t)
|
|||||||
if(n->right != N) {
|
if(n->right != N) {
|
||||||
typecheck(&n->right, Etype);
|
typecheck(&n->right, Etype);
|
||||||
n->type = n->right->type;
|
n->type = n->right->type;
|
||||||
|
if(n->type == T) {
|
||||||
|
*t0 = T;
|
||||||
|
return t0;
|
||||||
|
}
|
||||||
if(n->left != N)
|
if(n->left != N)
|
||||||
n->left->type = n->type;
|
n->left->type = n->type;
|
||||||
n->right = N;
|
n->right = N;
|
||||||
@ -886,6 +890,10 @@ dostruct(NodeList *l, int et)
|
|||||||
t = typ(et);
|
t = typ(et);
|
||||||
t->funarg = funarg;
|
t->funarg = funarg;
|
||||||
stotype(l, et, &t->type);
|
stotype(l, et, &t->type);
|
||||||
|
if(t->type == T && l != nil) {
|
||||||
|
t->broke = 1;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
if(!funarg)
|
if(!funarg)
|
||||||
checkwidth(t);
|
checkwidth(t);
|
||||||
return t;
|
return t;
|
||||||
|
@ -145,6 +145,7 @@ struct Type
|
|||||||
uchar copyany;
|
uchar copyany;
|
||||||
uchar local; // created in this file
|
uchar local; // created in this file
|
||||||
uchar deferwidth;
|
uchar deferwidth;
|
||||||
|
uchar broke;
|
||||||
|
|
||||||
Node* nod; // canonical OTYPE node
|
Node* nod; // canonical OTYPE node
|
||||||
int lineno;
|
int lineno;
|
||||||
|
@ -81,10 +81,12 @@ typecheck(Node **np, int top)
|
|||||||
n->typecheck = 2;
|
n->typecheck = 2;
|
||||||
|
|
||||||
redo:
|
redo:
|
||||||
if(n->sym)
|
|
||||||
walkdef(n);
|
|
||||||
|
|
||||||
lno = setlineno(n);
|
lno = setlineno(n);
|
||||||
|
if(n->sym) {
|
||||||
|
walkdef(n);
|
||||||
|
if(n->op == ONONAME)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
reswitch:
|
reswitch:
|
||||||
ok = 0;
|
ok = 0;
|
||||||
@ -683,6 +685,8 @@ reswitch:
|
|||||||
ok |= Erv;
|
ok |= Erv;
|
||||||
if(t->outtuple == 1) {
|
if(t->outtuple == 1) {
|
||||||
t = getoutargx(l->type)->type;
|
t = getoutargx(l->type)->type;
|
||||||
|
if(t == T)
|
||||||
|
goto error;
|
||||||
if(t->etype == TFIELD)
|
if(t->etype == TFIELD)
|
||||||
t = t->type;
|
t = t->type;
|
||||||
n->type = t;
|
n->type = t;
|
||||||
@ -1384,6 +1388,9 @@ typecheckaste(int op, Type *tstruct, NodeList *nl)
|
|||||||
|
|
||||||
lno = lineno;
|
lno = lineno;
|
||||||
|
|
||||||
|
if(tstruct->broke)
|
||||||
|
goto out;
|
||||||
|
|
||||||
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
|
if(nl != nil && nl->next == nil && (n = nl->n)->type != T)
|
||||||
if(n->type->etype == TSTRUCT && n->type->funarg) {
|
if(n->type->etype == TSTRUCT && n->type->funarg) {
|
||||||
setlineno(n);
|
setlineno(n);
|
||||||
@ -1592,7 +1599,6 @@ typecheckcomplit(Node **np)
|
|||||||
|
|
||||||
memset(hash, 0, sizeof hash);
|
memset(hash, 0, sizeof hash);
|
||||||
|
|
||||||
// TODO: dup detection
|
|
||||||
l = typecheck(&n->right /* sic */, Etype /* TODO | Edotarray */);
|
l = typecheck(&n->right /* sic */, Etype /* TODO | Edotarray */);
|
||||||
if((t = l->type) == T)
|
if((t = l->type) == T)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1699,6 +1705,7 @@ typecheckcomplit(Node **np)
|
|||||||
typecheck(&l->right, Erv);
|
typecheck(&l->right, Erv);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
l->left = newname(l->left->sym);
|
||||||
l->left->typecheck = 1;
|
l->left->typecheck = 1;
|
||||||
f = lookdot1(l->left->sym, t, t->type);
|
f = lookdot1(l->left->sym, t, t->type);
|
||||||
typecheck(&l->right, Erv);
|
typecheck(&l->right, Erv);
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
func f(a T) T { return a } // ERROR "T"
|
func f(a T) T { return a } // ERROR "undefined"
|
||||||
func main() {
|
func main() {
|
||||||
x := f(0);
|
x := f(0);
|
||||||
|
_ = x;
|
||||||
}
|
}
|
20
test/fixedbugs/bug208.go
Normal file
20
test/fixedbugs/bug208.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// errchk $G $D/$F.go
|
||||||
|
|
||||||
|
// Copyright 2009 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 struct
|
||||||
|
{
|
||||||
|
f int;
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ = T{f: 1}
|
||||||
|
|
||||||
|
// 6g used to get confused by the f:1 above
|
||||||
|
// and allow uses of f that would be silently
|
||||||
|
// dropped during the compilation.
|
||||||
|
var _ = f; // ERROR "undefined"
|
||||||
|
|
@ -167,10 +167,3 @@ BUG: errchk: bugs/bug193.go:14: missing expected error: 'shift'
|
|||||||
too many calls: 5
|
too many calls: 5
|
||||||
panic PC=xxx
|
panic PC=xxx
|
||||||
BUG: bug196
|
BUG: bug196
|
||||||
|
|
||||||
=========== bugs/bug198.go
|
|
||||||
bugs/bug198.go:8: undefined: T
|
|
||||||
bugs/bug198.go:8: T is not a type
|
|
||||||
bugs/bug198.go:8: too many arguments to return
|
|
||||||
bugs/bug198.go:10: too many arguments to CALL
|
|
||||||
BUG: errchk: compiler crashed
|
|
||||||
|
Loading…
Reference in New Issue
Block a user