forsyth: better constant detection, better incomplete ptr detection Reference: /n/atom/patch/applied/ccconstopt Date: Sun Aug 16 00:24:35 CES 2015 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/cc/sub.c Sun Aug 16 00:24:26 2015 +++ /sys/src/cmd/cc/sub.c Sun Aug 16 00:24:27 2015 @@ -662,7 +662,7 @@ Type *t1, *t2; int i, j, k; Node *n1; - long w; + long w, x; t1 = n->left->type; if(n->right == Z) @@ -692,7 +692,19 @@ if(n->op == OSUB) if(i == TIND && j == TIND) { w = n->right->type->link->width; - if(w < 1 || n->left->type->link == T || n->left->type->link->width < 1) + if(w < 1) { + snap(n->right->type->link); + w = n->right->type->link->width; + } + x = 0; + if(n->left->type->link != T) { + x = n->left->type->link->width; + if(x < 1) { + snap(n->left->type->link); + x = n->left->type->link->width; + } + } + if(w < 1 || x < 1) goto bad; n->type = types[ewidth[TIND] <= ewidth[TLONG]? TLONG: TVLONG]; if(1 && ewidth[TIND] > ewidth[TLONG]){ @@ -917,6 +929,10 @@ case ONOT: case OADDR: case OIND: + case OCOM: + case ONEG: + case OPOS: + case OTST: n = n->left; goto loop;