cc: remove nullwarn() from OCAST codegen, zap void casts

implicit casts would cause spurious "result of operation not used"
warnings such as ape's stdio putc() macro.

make (void) casts non-ops when the casted expression has no
side effects. this avoid spurious warning with ape's assert()
macro.
This commit is contained in:
cinap_lenrek 2019-06-19 23:50:33 +02:00
parent 159f96c534
commit 63191949b9
11 changed files with 16 additions and 35 deletions

View file

@ -376,10 +376,7 @@ cgen(Node *n, int result, Node *nn)
case OCAST:
if(result == D_NONE) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, D_NONE, Z);
cgen(l, D_NONE, Z);
break;
}
lg = result;

View file

@ -376,10 +376,7 @@ cgen(Node *n, int result, Node *nn)
case OCAST:
if(result == D_NONE) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, D_NONE, Z);
cgen(l, D_NONE, Z);
break;
}
lg = result;

View file

@ -399,10 +399,7 @@ cgenrel(Node *n, Node *nn, int inrel)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*
@ -927,7 +924,7 @@ cgen64(Node *n, Node *nn)
case OCAST:
if(nn == Z){
nullwarn(l, Z);
cgen(l, Z);
goto Out;
}
if(typeilp[n->type->etype] && typev[l->type->etype]){

View file

@ -976,10 +976,7 @@ cgen(Node *n, Node *nn)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*

View file

@ -326,7 +326,7 @@ brk:
break;
case OCAST:
if(l->type->etype == TUVLONG && typefd[n->type->etype])
if(l != Z && l->type->etype == TUVLONG && typefd[n->type->etype])
n->complex += 2;
break;

View file

@ -442,7 +442,7 @@ cgenrel(Node *n, Node *nn, int inrel)
case OCAST:
if(nn == Z) {
nullwarn(l, Z);
cgen(l, Z);
break;
}
/*

View file

@ -994,10 +994,7 @@ cgen(Node *n, Node *nn)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*

View file

@ -1073,6 +1073,11 @@ loop:
break;
case OCAST:
if(n->type == types[TVOID] && !side(l)){
n->left = Z;
n->type = T;
break;
}
if(castucom(n))
warn(n, "32-bit unsigned complement zero-extended to 64 bits");
ccom(l);

View file

@ -358,10 +358,7 @@ cgen(Node *n, Node *nn)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*

View file

@ -395,10 +395,7 @@ cgen(Node *n, Node *nn)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*

View file

@ -359,10 +359,7 @@ cgen(Node *n, Node *nn)
case OCAST:
if(nn == Z) {
if(n->type != types[TVOID])
nullwarn(l, Z);
else
cgen(l, Z);
cgen(l, Z);
break;
}
/*