Various 64-bit fixes.
[rsc] --rw-rw-r-- M 1428987 jmk sys 8788 Jan 28 10:53 sys/src/cmd/cc/scon.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/scon.c:1,5 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/scon.c:1,18
#include "cc.h"
+ static Node*
+ acast(Type *t, Node *n)
+ {
+ if(n->type->etype != t->etype || n->op == OBIT) {
+ n = new1(OCAST, n, Z);
+ if(nocast(n->left->type, t))
+ *n = *n->left;
+ n->type = t;
+ }
+ return n;
+ }
+
+
void
evconst(Node *n)
{
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/scon.c:426,435 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/scon.c:439,446
if(c2 % c1)
continue;
r = trm[j].node;
- if(r->type->etype != et) {
- r = new1(OCAST, r, Z);
- r->type = t;
- }
+ if(r->type->etype != et)
+ r = acast(t, r);
c2 = trm[j].mult/trm[i].mult;
if(c2 != 1 && c2 != -1) {
r = new1(OMUL, r, new(OCONST, Z, Z));
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/scon.c:438,447 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/scon.c:449,456
r->right->vconst = c2;
}
l = trm[i].node;
- if(l->type->etype != et) {
- l = new1(OCAST, l, Z);
- l->type = t;
- }
+ if(l->type->etype != et)
+ l = acast(t, l);
r = new1(OADD, l, r);
r->type = t;
if(c2 == -1)
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/scon.c:468,477 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/scon.c:477,484
if(c1 == 0)
continue;
r = trm[i].node;
- if(r->type->etype != et || r->op == OBIT) {
- r = new1(OCAST, r, Z);
- r->type = t;
- }
+ if(r->type->etype != et || r->op == OBIT)
+ r = acast(t, r);
if(c1 != 1 && c1 != -1) {
r = new1(OMUL, r, new(OCONST, Z, Z));
r->type = t;
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/scon.c:576,582 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/scon.c:583,589
if(n != Z)
if(!typefd[n->type->etype])
- if(!typev[n->type->etype])
+ if(!typev[n->type->etype] || ewidth[TVLONG] == ewidth[TIND])
switch(n->op) {
case OCAST:
[rsc] --rw-rw-r-- M 1428987 glenda sys 34377 Jan 28 10:53 sys/src/cmd/cc/sub.c
/n/sourcesdump/2006/0128/plan9/sys/src/cmd/cc/sub.c:684,690 -
/n/sourcesdump/2006/0129/plan9/sys/src/cmd/cc/sub.c:684,690
if(n->op == OSUB)
if(i == TIND && j == TIND) {
w = n->right->type->link->width;
- if(w < 1)
+ if(w < 1 || n->left->type->link == T || n->left->type->link->width < 1)
goto bad;
n->type = types[ewidth[TIND] <= ewidth[TLONG]? TLONG: TVLONG];
if(1 && ewidth[TIND] > ewidth[TLONG]){
|