mirror of
https://github.com/golang/go
synced 2024-11-22 18:14:42 -07:00
bug134
R=ken OCL=23532 CL=23532
This commit is contained in:
parent
4efad58d0a
commit
f1fe21a08f
@ -313,9 +313,9 @@ addmethod(Node *n, Type *t, int local)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(d == T)
|
if(d == T)
|
||||||
stotype(n, &pa->method);
|
stotype(n, 0, &pa->method);
|
||||||
else
|
else
|
||||||
stotype(n, &d->down);
|
stotype(n, 0, &d->down);
|
||||||
|
|
||||||
if(dflag())
|
if(dflag())
|
||||||
print("method %S of type %T\n", sf, pa);
|
print("method %S of type %T\n", sf, pa);
|
||||||
@ -472,36 +472,43 @@ funcbody(Node *n)
|
|||||||
* turn a parsed struct into a type
|
* turn a parsed struct into a type
|
||||||
*/
|
*/
|
||||||
Type**
|
Type**
|
||||||
stotype(Node *n, Type **t)
|
stotype(Node *n, int et, Type **t)
|
||||||
{
|
{
|
||||||
Type *f;
|
Type *f;
|
||||||
Iter save;
|
Iter save;
|
||||||
String *note;
|
String *note;
|
||||||
|
int lno;
|
||||||
|
|
||||||
|
lno = lineno;
|
||||||
n = listfirst(&save, &n);
|
n = listfirst(&save, &n);
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
note = nil;
|
note = nil;
|
||||||
if(n == N) {
|
if(n == N) {
|
||||||
*t = T;
|
*t = T;
|
||||||
|
lineno = lno;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lineno = n->lineno;
|
||||||
if(n->op == OLIST) {
|
if(n->op == OLIST) {
|
||||||
// recursive because it can be lists of lists
|
// recursive because it can be lists of lists
|
||||||
t = stotype(n, t);
|
t = stotype(n, et, t);
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n->op != ODCLFIELD || n->type == T)
|
if(n->op != ODCLFIELD || n->type == T)
|
||||||
fatal("stotype: oops %N\n", n);
|
fatal("stotype: oops %N\n", n);
|
||||||
|
|
||||||
|
if(et == TSTRUCT && n->type->etype == TFUNC)
|
||||||
|
yyerror("bad structure field type: %T", n->type);
|
||||||
|
|
||||||
switch(n->val.ctype) {
|
switch(n->val.ctype) {
|
||||||
case CTSTR:
|
case CTSTR:
|
||||||
note = n->val.u.sval;
|
note = n->val.u.sval;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
yyerror("structure field annotation must be string");
|
yyerror("field annotation must be string");
|
||||||
case CTxxx:
|
case CTxxx:
|
||||||
note = nil;
|
note = nil;
|
||||||
break;
|
break;
|
||||||
@ -546,7 +553,7 @@ dostruct(Node *n, int et)
|
|||||||
}
|
}
|
||||||
t = typ(et);
|
t = typ(et);
|
||||||
t->funarg = funarg;
|
t->funarg = funarg;
|
||||||
stotype(n, &t->type);
|
stotype(n, et, &t->type);
|
||||||
if(!funarg)
|
if(!funarg)
|
||||||
checkwidth(t);
|
checkwidth(t);
|
||||||
return t;
|
return t;
|
||||||
|
@ -707,7 +707,7 @@ void funchdr(Node*);
|
|||||||
void funcargs(Type*);
|
void funcargs(Type*);
|
||||||
void funcbody(Node*);
|
void funcbody(Node*);
|
||||||
Type* dostruct(Node*, int);
|
Type* dostruct(Node*, int);
|
||||||
Type** stotype(Node*, Type**);
|
Type** stotype(Node*, int, Type**);
|
||||||
Type* sortinter(Type*);
|
Type* sortinter(Type*);
|
||||||
void markdcl(void);
|
void markdcl(void);
|
||||||
void popdcl(void);
|
void popdcl(void);
|
||||||
|
11
test/fixedbugs/bug134.go
Normal file
11
test/fixedbugs/bug134.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
// errchk $G $D/$F.go
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
type T struct {
|
||||||
|
v (); // ERROR "field type"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user