]> Cypherpunks repositories - gostls13.git/commitdiff
minor bugs
authorKen Thompson <ken@golang.org>
Mon, 1 Sep 2008 21:37:32 +0000 (14:37 -0700)
committerKen Thompson <ken@golang.org>
Mon, 1 Sep 2008 21:37:32 +0000 (14:37 -0700)
R=r
OCL=14702
CL=14702

src/cmd/6g/align.c
src/cmd/gc/go.y
src/lib/math/pow.go
src/lib/math/sqrt.go
src/lib/math/tan.go

index cab2a93c11da5e3bbe2493a00488f3854db18a99..31f06b0f7c09b2567861f67b50df675896d61e6d 100644 (file)
@@ -102,10 +102,10 @@ dowidth(Type *t)
 {
        uint32 w;
 
-       w = 0;
        if(t == T)
                return;
 
+       w = 0;
        switch(t->etype) {
        default:
                fatal("dowidth: unknown type: %E", t->etype);
@@ -123,13 +123,13 @@ dowidth(Type *t)
        case TINT32:
        case TUINT32:
        case TFLOAT32:
-       case TPTR32:
+       case TPTR32:            // note lack of recursion
                w = 4;
                break;
        case TINT64:
        case TUINT64:
        case TFLOAT64:
-       case TPTR64:
+       case TPTR64:            // note lack of recursion
                w = 8;
                break;
        case TFLOAT80:
@@ -158,12 +158,9 @@ dowidth(Type *t)
                w = wptr;
                break;
        case TARRAY:
-               if(t->bound < 0)
-                       fatal("width of a dynamic array");
-               if(t->type == T)
-                       break;
                dowidth(t->type);
-               w = t->bound * t->type->width;
+               if(t->bound >= 0 && t->type != T)
+                       w = t->bound * t->type->width;
                break;
 
        case TSTRUCT:
index a59ab80116433816a7db507cb495889e9ed5be78..aa8c16df3ca2a55ac2056909a2c0aa013e62912b 100644 (file)
@@ -943,6 +943,7 @@ Atype:
 |      Afntypeh
 |      '*' Atype
        {
+               dowidth($2);
                $$ = ptrto($2);
        }
 
@@ -966,6 +967,7 @@ Btype:
 |      Bfntypeh
 |      '*' Btype
        {
+               dowidth($2);
                $$ = ptrto($2);
        }
 |      '*' lname
index ad7de595edf298143d95516ba5465f03c762727e..8adb72132a9104db72c47bca998ec72812eb587a 100644 (file)
@@ -29,7 +29,7 @@ pow(arg1,arg2 float64) float64
 
                temp = floor(arg2);
                if temp != arg2 {
-                       panic sys.NaN();
+                       panic(sys.NaN());
                }
 
                l = long(temp);
index 8fe6ef2f011a75e11e43f6ec648b86044399958e..76b499e88048c43ceb45107e1df5719330adb121 100644 (file)
@@ -49,9 +49,11 @@ sqrt(arg float64) float64
                exp = exp + 60;
        }
        if exp >= 0 {
-               temp = temp * float64(1 << (exp/2));
+               exp = 1 << uint(exp/2);
+               temp = temp * float64(exp);
        } else {
-               temp = temp / float64(1 << (-exp/2));
+               exp = 1 << uint(-exp/2);
+               temp = temp / float64(exp);
        }
 
        for i=0; i<=4; i=i+1 {
index 5d9d5685a75933e1058788bd6bc3622c0279ed79..9def4d9cf3c3e362da89da38cbea372ea8723c93 100644 (file)
@@ -60,7 +60,7 @@ tan(arg float64) float64
 
        if flag {
                if(temp == 0) {
-                       panic sys.NaN();
+                       panic(sys.NaN());
                }
                temp = 1/temp;
        }