Skip to content

Commit

Permalink
fix warnings/errors found by static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Nov 13, 2011
1 parent 6365f53 commit 19c05b6
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/backend/cgelem.c
Expand Up @@ -339,7 +339,7 @@ STATIC elem *fixconvop(elem *e)
elem **pe;
unsigned cop,icop,op;
tym_t tycop,tym,tyme;
static char invconvtab[] =
static unsigned char invconvtab[] =
{
OPbool, // OPb_8
OPs32_d, // OPd_s32
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgreg.c
Expand Up @@ -48,7 +48,7 @@ static int *weights;

void cgreg_init()
{
if (!config.flags4 & CFG4optimized)
if (!(config.flags4 & CFG4optimized))
return;

// Use calloc() instead because sometimes the alloc is too large
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cod3.c
Expand Up @@ -321,7 +321,7 @@ void cod3_set64()

void cod3_align()
{
static char nops[7] = { 0x90,0x90,0x90,0x90,0x90,0x90,0x90 };
static unsigned char nops[7] = { 0x90,0x90,0x90,0x90,0x90,0x90,0x90 };
unsigned nbytes;
#if OMFOBJ
if (config.flags4 & CFG4speed) // if optimized for speed
Expand Down
32 changes: 16 additions & 16 deletions src/backend/evalu8.c
Expand Up @@ -1664,7 +1664,7 @@ elem * evalu8(elem *e)
case OPgt:
if (!tyfloating(tym))
goto Lnle;
i ^= d1 > d2;
i ^= (int)(d1 > d2);
e->EV.Vint = i;
break;

Expand All @@ -1674,14 +1674,14 @@ elem * evalu8(elem *e)
case OPle:
if (uns)
{
i ^= ((targ_ullong) l1) <= ((targ_ullong) l2);
i ^= (int)(((targ_ullong) l1) <= ((targ_ullong) l2));
}
else
{
if (tyfloating(tym))
i ^= d1 <= d2;
i ^= (int)(d1 <= d2);
else
i ^= l1 <= l2;
i ^= (int)(l1 <= l2);
}
e->EV.Vint = i;
break;
Expand All @@ -1691,7 +1691,7 @@ elem * evalu8(elem *e)
case OPge:
if (!tyfloating(tym))
goto Lnlt;
i ^= d1 >= d2;
i ^= (int)(d1 >= d2);
e->EV.Vint = i;
break;

Expand All @@ -1701,14 +1701,14 @@ elem * evalu8(elem *e)
case OPlt:
if (uns)
{
i ^= ((targ_ullong) l1) < ((targ_ullong) l2);
i ^= (int)(((targ_ullong) l1) < ((targ_ullong) l2));
}
else
{
if (tyfloating(tym))
i ^= d1 < d2;
i ^= (int)(d1 < d2);
else
i ^= l1 < l2;
i ^= (int)(l1 < l2);
}
e->EV.Vint = i;
break;
Expand All @@ -1725,33 +1725,33 @@ elem * evalu8(elem *e)
isnan(e2->EV.Vcfloat.re) || isnan(e2->EV.Vcfloat.im))
i ^= 1;
else
i ^= (e1->EV.Vcfloat.re == e2->EV.Vcfloat.re) &&
(e1->EV.Vcfloat.im == e2->EV.Vcfloat.im);
i ^= (int)((e1->EV.Vcfloat.re == e2->EV.Vcfloat.re) &&
(e1->EV.Vcfloat.im == e2->EV.Vcfloat.im));
break;
case TYcdouble:
if (isnan(e1->EV.Vcdouble.re) || isnan(e1->EV.Vcdouble.im) ||
isnan(e2->EV.Vcdouble.re) || isnan(e2->EV.Vcdouble.im))
i ^= 1;
else
i ^= (e1->EV.Vcdouble.re == e2->EV.Vcdouble.re) &&
(e1->EV.Vcdouble.im == e2->EV.Vcdouble.im);
i ^= (int)((e1->EV.Vcdouble.re == e2->EV.Vcdouble.re) &&
(e1->EV.Vcdouble.im == e2->EV.Vcdouble.im));
break;
case TYcldouble:
if (isnan(e1->EV.Vcldouble.re) || isnan(e1->EV.Vcldouble.im) ||
isnan(e2->EV.Vcldouble.re) || isnan(e2->EV.Vcldouble.im))
i ^= 1;
else
i ^= (e1->EV.Vcldouble.re == e2->EV.Vcldouble.re) &&
(e1->EV.Vcldouble.im == e2->EV.Vcldouble.im);
i ^= (int)((e1->EV.Vcldouble.re == e2->EV.Vcldouble.re) &&
(e1->EV.Vcldouble.im == e2->EV.Vcldouble.im));
break;
default:
i ^= d1 == d2;
i ^= (int)(d1 == d2);
break;
}
//printf("%Lg + %Lgi, %Lg + %Lgi\n", e1->EV.Vcldouble.re, e1->EV.Vcldouble.im, e2->EV.Vcldouble.re, e2->EV.Vcldouble.im);
}
else
i ^= l1 == l2;
i ^= (int)(l1 == l2);
e->EV.Vint = i;
break;

Expand Down
12 changes: 6 additions & 6 deletions src/backend/rtlsym.c
Expand Up @@ -85,12 +85,12 @@ void rtlsym_init()
#endif

#undef SYMBOL_Z
#define SYMBOL_Z(e, fl, saved, n, flags, ty) \
if (ty) rtlsym[RTLSYM_##e]->Stype = ty; \
if (fl != FLfunc) rtlsym[RTLSYM_##e]->Sfl = fl; \
if (flags) rtlsym[RTLSYM_##e]->Sflags = flags; \
if (saved != FREGSAVED) rtlsym[RTLSYM_##e]->Sregsaved = saved; \
strcpy(rtlsym[RTLSYM_##e]->Sident, n); \
#define SYMBOL_Z(e, fl, saved, n, flags, ty) \
if (ty) rtlsym[RTLSYM_##e]->Stype = (ty); \
if ((fl) != FLfunc) rtlsym[RTLSYM_##e]->Sfl = (fl); \
if (flags) rtlsym[RTLSYM_##e]->Sflags = (flags); \
if ((saved) != FREGSAVED) rtlsym[RTLSYM_##e]->Sregsaved = (saved); \
strcpy(rtlsym[RTLSYM_##e]->Sident, (n)); \

RTLSYMS
}
Expand Down
6 changes: 5 additions & 1 deletion src/iasm.c
Expand Up @@ -52,7 +52,9 @@
#include "code.h"
#include "iasm.h"

#if DMDV1
#undef _DH
#endif

// I32 isn't set correctly yet because this is the front end, and I32
// is a backend flag
Expand Down Expand Up @@ -3897,7 +3899,7 @@ STATIC OPND *asm_una_exp()
ASM_JUMPTYPE ajt = ASM_JUMPTYPE_UNSPECIFIED;
char bPtr = 0;

switch (tok_value)
switch ((int)tok_value)
{
#if 0
case TOKand:
Expand Down Expand Up @@ -4401,7 +4403,9 @@ Statement *AsmStatement::semantic(Scope *sc)
FuncDeclaration *fd = sc->parent->isFuncDeclaration();

assert(fd);
#if DMDV1
fd->inlineAsm = 1;
#endif

if (!tokens)
return NULL;
Expand Down

0 comments on commit 19c05b6

Please sign in to comment.