summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-01-26 17:06:20 -0800
committerRuss Cox <rsc@golang.org>2009-01-26 17:06:20 -0800
commit4e941ce970a4294c098806c9a0c6fce16ade8234 (patch)
tree47b948a181d2dbb1ebf1574703abfcf25b336b98 /src
parentc4103b7c230cef37999a93af7ed62bb5ed411752 (diff)
downloadgolang-4e941ce970a4294c098806c9a0c6fce16ade8234.tar.gz
bug134
R=ken OCL=23532 CL=23532
Diffstat (limited to 'src')
-rw-r--r--src/cmd/gc/dcl.c19
-rw-r--r--src/cmd/gc/go.h2
2 files changed, 14 insertions, 7 deletions
diff --git a/src/cmd/gc/dcl.c b/src/cmd/gc/dcl.c
index a60637c25..edac4ca2c 100644
--- a/src/cmd/gc/dcl.c
+++ b/src/cmd/gc/dcl.c
@@ -313,9 +313,9 @@ addmethod(Node *n, Type *t, int local)
}
if(d == T)
- stotype(n, &pa->method);
+ stotype(n, 0, &pa->method);
else
- stotype(n, &d->down);
+ stotype(n, 0, &d->down);
if(dflag())
print("method %S of type %T\n", sf, pa);
@@ -472,36 +472,43 @@ funcbody(Node *n)
* turn a parsed struct into a type
*/
Type**
-stotype(Node *n, Type **t)
+stotype(Node *n, int et, Type **t)
{
Type *f;
Iter save;
String *note;
+ int lno;
+ lno = lineno;
n = listfirst(&save, &n);
loop:
note = nil;
if(n == N) {
*t = T;
+ lineno = lno;
return t;
}
+ lineno = n->lineno;
if(n->op == OLIST) {
// recursive because it can be lists of lists
- t = stotype(n, t);
+ t = stotype(n, et, t);
goto next;
}
if(n->op != ODCLFIELD || n->type == T)
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) {
case CTSTR:
note = n->val.u.sval;
break;
default:
- yyerror("structure field annotation must be string");
+ yyerror("field annotation must be string");
case CTxxx:
note = nil;
break;
@@ -546,7 +553,7 @@ dostruct(Node *n, int et)
}
t = typ(et);
t->funarg = funarg;
- stotype(n, &t->type);
+ stotype(n, et, &t->type);
if(!funarg)
checkwidth(t);
return t;
diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h
index e1f64b542..461c00b21 100644
--- a/src/cmd/gc/go.h
+++ b/src/cmd/gc/go.h
@@ -707,7 +707,7 @@ void funchdr(Node*);
void funcargs(Type*);
void funcbody(Node*);
Type* dostruct(Node*, int);
-Type** stotype(Node*, Type**);
+Type** stotype(Node*, int, Type**);
Type* sortinter(Type*);
void markdcl(void);
void popdcl(void);