]> Cypherpunks repositories - gostls13.git/commitdiff
bug103 - but the fix caused other
authorKen Thompson <ken@golang.org>
Sat, 20 Sep 2008 21:59:15 +0000 (14:59 -0700)
committerKen Thompson <ken@golang.org>
Sat, 20 Sep 2008 21:59:15 +0000 (14:59 -0700)
things to break. hopefully all fixed
now.

R=r
OCL=15597
CL=15597

src/cmd/6g/obj.c
src/cmd/gc/go.h
src/cmd/gc/subr.c
src/cmd/gc/walk.c

index e6c34bd0722eafec0dc439eb03809107d85dc3f1..0f187fefedac7127d5bc40ecd0735eef37630657 100644 (file)
@@ -478,7 +478,7 @@ dumpsignatures(void)
                        continue;
 
                et = t->etype;
-               if(et != TSTRUCT && et != TINTER)
+               if(t->method == T && et != TINTER)
                        continue;
 
                s = d->dsym;
@@ -549,7 +549,7 @@ dumpsignatures(void)
 
                t = d->dtype;
                et = t->etype;
-               if(et != TSTRUCT && et != TINTER)
+               if(t->method == T && et != TINTER)
                        continue;
 
                s = d->dsym;
index 639aa9236d14832ed6a3319655529b02a2829552..178f28ef32f28e6b89a33d48dc11085d4dc16391 100644 (file)
@@ -563,6 +563,7 @@ int isptrto(Type*, int);
 int    isptrarray(Type*);
 int    isptrdarray(Type*);
 int    isinter(Type*);
+int    ismethod(Type*);
 int    bytearraysz(Type*);
 int    eqtype(Type*, Type*, int);
 void   argtype(Node*, Type*);
index c1bb941fc817d107fae7ed341c793d65141c3ff5..15e4eb7e038178cd30af7ab825e8d95026dd6a40 100644 (file)
@@ -1224,6 +1224,20 @@ isinter(Type *t)
        return 0;
 }
 
+int
+ismethod(Type *t)
+{
+       // OLD WAY
+       if(isptrto(t, TSTRUCT))
+               return 1;
+       return 0;
+
+       // NEW WAY - but doesnt work yet
+       if(t != T && t->method != T)
+               return 1;
+       return 0;
+}
+
 int
 bytearraysz(Type *t)
 {
index 300b78cea86dac034078340b4e4c247d1e3bfc1e..9f27ac753e9254cf98455143c85468a9745b7e74 100644 (file)
@@ -330,8 +330,18 @@ loop:
                }
 
                n->type = *getoutarg(t);
-               if(t->outtuple == 1)
+               switch(t->outtuple) {
+               case 0:
+                       if(top == Erv) {
+                               yyerror("function requires a return type");
+                               n->type = types[TINT32];
+                       }
+                       break;
+
+               case 1:
                        n->type = n->type->type->type;
+                       break;
+               }
 
                walktype(n->right, Erv);
 
@@ -1381,7 +1391,7 @@ lookdot(Node *n, Type *f)
                if(f->sym != s)
                        continue;
                if(r != T) {
-                       yyerror("ambiguous DOT reference %s", s->name);
+                       yyerror("ambiguous DOT reference %S", s);
                        break;
                }
                r = f;
@@ -1432,7 +1442,7 @@ walkdot(Node *n)
 
        f = lookdot(n->right, t->method);
        if(f == T) {
-               yyerror("undefined DOT %s", n->right->sym->name);
+               yyerror("undefined DOT %S", n->right->sym);
                return;
        }
 
@@ -1579,11 +1589,11 @@ ascompat(Type *t1, Type *t2)
 //             return 1;
 
        if(isinter(t1))
-               if(isptrto(t2, TSTRUCT) || isinter(t2))
+               if(ismethod(t2) || isinter(t2))
                        return 1;
 
        if(isinter(t2))
-               if(isptrto(t1, TSTRUCT))
+               if(ismethod(t1))
                        return 1;
 
        if(isptrdarray(t1))
@@ -1608,7 +1618,7 @@ prcompat(Node *n)
 
 loop:
        if(l == N) {
-               walktype(r, Erv);
+               walktype(r, Etop);
                return r;
        }
 
@@ -1673,7 +1683,7 @@ nodpanic(int32 lineno)
        on = syslook("panicl", 0);
        n = nodintconst(lineno);
        n = nod(OCALL, on, n);
-       walktype(n, Erv);
+       walktype(n, Etop);
        return n;
 }
 
@@ -2027,7 +2037,7 @@ mapop(Node *n, int top)
                argtype(on, t->type);   // any-4
 
                r = nod(OCALL, on, r);
-               walktype(r, Erv);
+               walktype(r, Etop);
                break;
 
        assign2:
@@ -2056,7 +2066,7 @@ mapop(Node *n, int top)
                argtype(on, t->type);   // any-4
 
                r = nod(OCALL, on, r);
-               walktype(r, Erv);
+               walktype(r, Etop);
                break;
 
        access2:
@@ -2446,7 +2456,7 @@ diagnamed(Type *t)
        if(isinter(t))
                if(t->sym == S)
                        yyerror("interface type must be named");
-       if(isptrto(t, TSTRUCT))
+       if(ismethod(t))
                if(t->type == T || t->type->sym == S)
                        yyerror("structure type must be named");
 }
@@ -2460,7 +2470,7 @@ isandss(Type *lt, Node *r)
 
        rt = r->type;
        if(isinter(lt)) {
-               if(isptrto(rt, TSTRUCT)) {
+               if(ismethod(rt)) {
                        o = OS2I;
                        goto ret;
                }
@@ -2470,7 +2480,7 @@ isandss(Type *lt, Node *r)
                }
        }
 
-       if(isptrto(lt, TSTRUCT)) {
+       if(ismethod(lt)) {
                if(isinter(rt)) {
                        o = OI2S;
                        goto ret;