Skip to content

Commit

Permalink
Merge pull request #3598 from andron/fix-warnings
Browse files Browse the repository at this point in the history
Fix minor warning issues
  • Loading branch information
WalterBright committed Jun 6, 2014
2 parents 45dd224 + 4b27917 commit 9180ba2
Show file tree
Hide file tree
Showing 27 changed files with 44 additions and 84 deletions.
3 changes: 2 additions & 1 deletion src/backend/strtold.c
Expand Up @@ -145,10 +145,11 @@ longdouble strtold_dm(const char *p,char **endp)
int pow;
int ndigits;
const char *pinit = p;
#if __DMC__
static char infinity[] = "infinity";
static char nans[] = "nans";
#endif
unsigned int old_cw;
unsigned int old_status;

#if _WIN32 && __DMC__
fenv_t flagp;
Expand Down
1 change: 0 additions & 1 deletion src/cast.c
Expand Up @@ -106,7 +106,6 @@ Expression *implicitCastTo(Expression *e, Scope *sc, Type *t)
void visit(StringExp *e)
{
//printf("StringExp::implicitCastTo(%s of type %s) => %s\n", e->toChars(), e->type->toChars(), t->toChars());
unsigned char committed = e->committed;
visit((Expression *)e);
if (result->op == TOKstring)
{
Expand Down
1 change: 0 additions & 1 deletion src/class.c
Expand Up @@ -1141,7 +1141,6 @@ FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf)
goto Lfdmatch;
}

Lambig:
fdambig = fd;
//printf("Lambig fdambig = %s %s [%s]\n", fdambig->toChars(), fdambig->type->toChars(), fdambig->loc.toChars());
continue;
Expand Down
3 changes: 1 addition & 2 deletions src/clone.c
Expand Up @@ -160,7 +160,6 @@ bool needOpAssign(StructDeclaration *sd)
goto Lneed;
}
}
Ldontneed:
//printf("\tdontneed\n");
return false;

Expand Down Expand Up @@ -447,7 +446,7 @@ FuncDeclaration *hasIdentityOpEquals(AggregateDeclaration *ad, Scope *sc)

FuncDeclaration *buildOpEquals(StructDeclaration *sd, Scope *sc)
{
if (FuncDeclaration *f = hasIdentityOpEquals(sd, sc))
if (hasIdentityOpEquals(sd, sc))
{
sd->hasIdentityEquals = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/constfold.c
Expand Up @@ -666,7 +666,7 @@ Expression *Xor(Type *type, Expression *e1, Expression *e2)
Expression *Equal(TOK op, Type *type, Expression *e1, Expression *e2)
{ Expression *e;
Loc loc = e1->loc;
int cmp;
int cmp = 0;
real_t r1;
real_t r2;

Expand Down
2 changes: 1 addition & 1 deletion src/ctfeexpr.c
Expand Up @@ -113,7 +113,7 @@ char *VoidInitExp::toChars()
// Same as getFieldIndex, but checks for a direct match with the VarDeclaration
int findFieldIndexByName(StructDeclaration *sd, VarDeclaration *v)
{
for (int i = 0; i < sd->fields.dim; ++i)
for (size_t i = 0; i < sd->fields.dim; ++i)
{
if (sd->fields[i] == v)
return i;
Expand Down
6 changes: 3 additions & 3 deletions src/declaration.c
Expand Up @@ -330,7 +330,7 @@ void TypedefDeclaration::semantic(Scope *sc)
{
sem = SemanticIn;
parent = sc->parent;
int errors = global.errors;
unsigned int errors = global.errors;
Type *savedbasetype = basetype;
basetype = basetype->semantic(loc, sc);
if (errors != global.errors)
Expand Down Expand Up @@ -373,7 +373,7 @@ void TypedefDeclaration::semantic2(Scope *sc)
if (init)
{
Initializer *savedinit = init;
int errors = global.errors;
unsigned int errors = global.errors;
init = init->semantic(sc, basetype, INITinterpret);
if (errors != global.errors || init->isErrorInitializer())
{
Expand Down Expand Up @@ -504,7 +504,7 @@ void AliasDeclaration::semantic(Scope *sc)
// type. If it is a symbol, then aliassym is set and type is NULL -
// toAlias() will return aliasssym.

int errors = global.errors;
unsigned int errors = global.errors;
Type *savedtype = type;

Dsymbol *s;
Expand Down
2 changes: 1 addition & 1 deletion src/dsymbol.c
Expand Up @@ -1444,7 +1444,7 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags)
// Check for multi-dimensional opDollar(dim) template.
if (TemplateDeclaration *td = s->isTemplateDeclaration())
{
dinteger_t dim;
dinteger_t dim = 0;
if (exp->op == TOKarray)
{
dim = ((ArrayExp *)exp)->currentDimension;
Expand Down
7 changes: 0 additions & 7 deletions src/e2ir.c
Expand Up @@ -1569,7 +1569,6 @@ elem *toElem(Expression *e, IRState *irs)
// Single dimension array allocations
Expression *arg = (*ne->arguments)[0]; // gives array length
e = arg->toElem(irs);
d_uns64 elemsize = tda->next->size();

// call _d_newT(ti, arg)
e = el_param(e, ne->type->getTypeInfo(NULL)->toElem(irs));
Expand Down Expand Up @@ -1599,9 +1598,7 @@ elem *toElem(Expression *e, IRState *irs)
else if (t->ty == Tpointer)
{
TypePointer *tp = (TypePointer *)t;
d_uns64 elemsize = tp->next->size();
Expression *di = tp->next->defaultInit();
d_uns64 disize = di->type->size();

// call _d_newitemT(ti)
e = ne->type->getTypeInfo(NULL)->toElem(irs);
Expand Down Expand Up @@ -1946,7 +1943,6 @@ elem *toElem(Expression *e, IRState *irs)
Type *tb2 = ce->e2->type->toBasetype();

Type *ta = (tb1->ty == Tarray || tb1->ty == Tsarray) ? tb1 : tb2;
Type *tn = ta->nextOf();

elem *e;
if (ce->e1->op == TOKcat)
Expand Down Expand Up @@ -2359,7 +2355,6 @@ elem *toElem(Expression *e, IRState *irs)
//printf("Lpair %s\n", ae->toChars());
Type *tb = ta->nextOf()->toBasetype();
unsigned sz = tb->size();
tym_t tym = totym(ae->type);

elem *n1 = are->e1->toElem(irs);
elem *elwr = are->lwr ? are->lwr->toElem(irs) : NULL;
Expand Down Expand Up @@ -5020,7 +5015,6 @@ elem *toElem(Expression *e, IRState *irs)
e1 = el_bin(OPadd, TYnptr, e1, el_long(TYsize_t, sle->soffset));
}
e1 = el_bin(OPadd, TYnptr, e1, el_long(TYsize_t, v->offset));
elem *ec = e1; // pointer to destination

elem *ep = el->toElem(irs);

Expand Down Expand Up @@ -5061,7 +5055,6 @@ elem *toElem(Expression *e, IRState *irs)
{
// Initialize the hidden 'this' pointer
assert(sle->sd->fields.dim);
ThisDeclaration *v = sle->sd->fields[sle->sd->fields.dim - 1]->isThisDeclaration();

elem *e1;
if (tybasic(stmp->Stype->Tty) == TYnptr)
Expand Down
11 changes: 4 additions & 7 deletions src/expression.c
Expand Up @@ -2869,7 +2869,7 @@ void realToMangleBuffer(OutBuffer *buf, real_t value)
char buffer[BUFFER_LEN];
size_t n = ld_sprint(buffer, 'A', value);
assert(n < BUFFER_LEN);
for (int i = 0; i < n; i++)
for (size_t i = 0; i < n; i++)
{ char c = buffer[i];

switch (c)
Expand Down Expand Up @@ -4081,7 +4081,7 @@ StringExp *ArrayLiteralExp::toStringExp()
OutBuffer buf;
if (elements)
{
for (int i = 0; i < elements->dim; ++i)
for (size_t i = 0; i < elements->dim; ++i)
{
Expression *ch = (*elements)[i];
if (ch->op != TOKint64)
Expand Down Expand Up @@ -8959,7 +8959,7 @@ Expression *CallExp::semantic(Scope *sc)

if (!arguments)
arguments = new Expressions();
int olderrors = global.errors;
unsigned int olderrors = global.errors;
type = functionParameters(loc, sc, (TypeFunction *)(t1), tthis, arguments, f);
if (olderrors != global.errors)
return new ErrorExp();
Expand Down Expand Up @@ -10659,7 +10659,6 @@ Expression *IndexExp::semantic(Scope *sc)
e2 = e2->implicitCastTo(sc, Type::tsize_t);
if (e2->type == Type::terror)
return new ErrorExp();
TypeSArray *tsa = (TypeSArray *)t1;
e->type = t1->nextOf();
break;
}
Expand Down Expand Up @@ -10778,7 +10777,7 @@ Expression *IndexExp::modifiableLvalue(Scope *sc, Expression *e)
modifiable = 1;
Type *t1 = e1->type->toBasetype();
if (t1->ty == Taarray)
{ TypeAArray *taa = (TypeAArray *)t1;
{
Type *t2b = e2->type->toBasetype();
if (t2b->ty == Tarray && t2b->nextOf()->isMutable())
error("associative arrays can only be assigned values with immutable keys, not %s", e2->type->toChars());
Expand Down Expand Up @@ -12724,8 +12723,6 @@ Expression *PowExp::semantic(Scope *sc)
// For built-in numeric types, there are several cases.
// TODO: backend support, especially for e1 ^^ 2.

bool wantSqrt = false;

// First, attempt to fold the expression.
e = optimize(WANTvalue);
if (e->op != TOKpow)
Expand Down
14 changes: 6 additions & 8 deletions src/func.c
Expand Up @@ -1300,7 +1300,7 @@ void FuncDeclaration::semantic3(Scope *sc)
sc2->fieldinit = NULL;
sc2->fieldinit_dim = 0;

if (AggregateDeclaration *ad = isMember2())
if (isMember2())
{
FuncLiteralDeclaration *fld = isFuncLiteralDeclaration();
if (fld && !sc->intypeof)
Expand Down Expand Up @@ -1703,7 +1703,7 @@ void FuncDeclaration::semantic3(Scope *sc)
}

// Check for errors related to 'nothrow'.
int nothrowErrors = global.errors;
unsigned int nothrowErrors = global.errors;
int blockexit = fbody->blockExit(this, f->isnothrow);
if (f->isnothrow && (global.errors != nothrowErrors) )
::error(loc, "%s '%s' is nothrow yet may throw", kind(), toPrettyChars());
Expand Down Expand Up @@ -1757,7 +1757,7 @@ void FuncDeclaration::semantic3(Scope *sc)
else
{
// Check for errors related to 'nothrow'.
int nothrowErrors = global.errors;
unsigned int nothrowErrors = global.errors;
int blockexit = fbody->blockExit(this, f->isnothrow);
if (f->isnothrow && (global.errors != nothrowErrors) )
::error(loc, "%s '%s' is nothrow yet may throw", kind(), toPrettyChars());
Expand Down Expand Up @@ -2052,7 +2052,7 @@ void FuncDeclaration::semantic3(Scope *sc)
{
Statement *s = new ExpStatement(Loc(), e);
s = s->semantic(sc2);
int nothrowErrors = global.errors;
unsigned int nothrowErrors = global.errors;
bool isnothrow = f->isnothrow & !(flags & FUNCFLAGnothrowInprocess);
int blockexit = s->blockExit(this, isnothrow);
if (f->isnothrow && (global.errors != nothrowErrors) )
Expand Down Expand Up @@ -3012,7 +3012,6 @@ MATCH FuncDeclaration::leastAsSpecialized(FuncDeclaration *g)
TypeFunction *tf = (TypeFunction *)type;
TypeFunction *tg = (TypeFunction *)g->type;
size_t nfparams = Parameter::dim(tf->parameters);
size_t ngparams = Parameter::dim(tg->parameters);

/* If both functions have a 'this' pointer, and the mods are not
* the same and g's is not const, then this is less specialized.
Expand Down Expand Up @@ -3225,7 +3224,6 @@ FuncDeclaration *resolveFuncCall(Loc loc, Scope *sc, Dsymbol *s,
}
}

Lerror:
/* Failed to find a best match.
* Do nothing or print error.
*/
Expand Down Expand Up @@ -4017,7 +4015,7 @@ void FuncDeclaration::checkNestedReference(Scope *sc, Loc loc)
if (fdthis != this)
{
bool found = false;
for (int i = 0; i < siblingCallers.dim; ++i)
for (size_t i = 0; i < siblingCallers.dim; ++i)
{
if (siblingCallers[i] == fdthis)
found = true;
Expand Down Expand Up @@ -4092,7 +4090,7 @@ bool checkEscapingSiblings(FuncDeclaration *f, FuncDeclaration *outerFunc, void

//printf("checkEscapingSiblings(f = %s, outerfunc = %s)\n", f->toChars(), outerFunc->toChars());
bool bAnyClosures = false;
for (int i = 0; i < f->siblingCallers.dim; ++i)
for (size_t i = 0; i < f->siblingCallers.dim; ++i)
{
FuncDeclaration *g = f->siblingCallers[i];
if (g->isThis() || g->tookAddressOf)
Expand Down
2 changes: 0 additions & 2 deletions src/glue.c
Expand Up @@ -742,7 +742,6 @@ void FuncDeclaration::toObjFile(bool multiobj)
FuncDeclaration *func = this;
ClassDeclaration *cd = func->parent->isClassDeclaration();
int reverse;
int has_arguments;

//printf("FuncDeclaration::toObjFile(%p, %s.%s)\n", func, parent->toChars(), func->toChars());

Expand Down Expand Up @@ -997,7 +996,6 @@ void FuncDeclaration::toObjFile(bool multiobj)

assert(func->type->ty == Tfunction);
tf = (TypeFunction *)(func->type);
has_arguments = (tf->linkage == LINKd) && (tf->varargs == 1);
retmethod = retStyle(tf);
if (retmethod == RETstack)
{
Expand Down
5 changes: 2 additions & 3 deletions src/iasm.c
Expand Up @@ -457,8 +457,10 @@ static void asm_make_modrm_byte(
unsigned usFlags,
OPND *popnd, OPND *popnd2);
static regm_t asm_modify_regs(PTRNTAB ptb, OPND *popnd1, OPND *popnd2);
#ifdef DEBUG
static void asm_output_flags(opflag_t usFlags);
static void asm_output_popnd(OPND *popnd);
#endif
static unsigned asm_type_size(Type * ptype);
static opflag_t asm_float_type_size(Type * ptype, opflag_t *pusFloat);
static OPND *asm_mul_exp();
Expand Down Expand Up @@ -1232,7 +1234,6 @@ static code *asm_emit(Loc loc,
#else
#define emit(op) ((void)(op))
#endif
Identifier *id;
// unsigned us;
unsigned char *puc;
unsigned usDefaultseg;
Expand Down Expand Up @@ -4623,8 +4624,6 @@ Statement* asmSemantic(AsmStatement *s, Scope *sc)
OPND *o1 = NULL,*o2 = NULL, *o3 = NULL, *o4 = NULL;
PTRNTAB ptb;
unsigned usNumops;
unsigned char uchPrefix = 0;
char *pszLabel = NULL;
FuncDeclaration *fd = sc->parent->isFuncDeclaration();

assert(fd);
Expand Down
2 changes: 1 addition & 1 deletion src/init.c
Expand Up @@ -822,7 +822,7 @@ Initializer *ExpInitializer::semantic(Scope *sc, Type *t, NeedInterpret needInte
if (exp->op == TOKerror)
return new ErrorInitializer();

int olderrors = global.errors;
unsigned int olderrors = global.errors;
if (needInterpret)
{
// If the result will be implicitly cast, move the cast into CTFE
Expand Down
1 change: 0 additions & 1 deletion src/inline.c
Expand Up @@ -832,7 +832,6 @@ Expression *doInline(Expression *e, InlineDoState *ids)
{
if (vd == ids->from[i])
{
VarDeclaration *vto = (VarDeclaration *)ids->to[i];
if (vd->init && !vd->init->isVoidInitializer())
{
result = vd->init->toExpression();
Expand Down
8 changes: 3 additions & 5 deletions src/interpret.c
Expand Up @@ -137,7 +137,6 @@ size_t CtfeStack::maxStackUsage()

void CtfeStack::startFrame(Expression *thisexp)
{
size_t oldframe = framepointer;
frames.push((void *)(size_t)(framepointer));
savedThis.push(localThis);
framepointer = stackPointer();
Expand Down Expand Up @@ -693,7 +692,6 @@ void ctfeCompile(FuncDeclaration *fd)
{
Type *tb = fd->type->toBasetype();
assert(tb->ty == Tfunction);
TypeFunction *tf = (TypeFunction *)tb;
for (size_t i = 0; i < fd->parameters->dim; i++)
{
VarDeclaration *v = (*fd->parameters)[i];
Expand Down Expand Up @@ -6855,7 +6853,7 @@ Expression *foreachApplyUtf(InterState *istate, Expression *str, Expression *del
}
else
buflen = (indx + 4 > len) ? len - indx : 4;
for (int i = 0; i < buflen; ++i)
for (size_t i = 0; i < buflen; ++i)
{
Expression * r = (*ale->elements)[indx + i];
assert(r->op == TOKint64);
Expand All @@ -6880,7 +6878,7 @@ Expression *foreachApplyUtf(InterState *istate, Expression *str, Expression *del
}
else
buflen = (indx + 2 > len) ? len - indx : 2;
for (int i=0; i < buflen; ++i)
for (size_t i=0; i < buflen; ++i)
{
Expression * r = (*ale->elements)[indx + i];
assert(r->op == TOKint64);
Expand Down Expand Up @@ -7071,7 +7069,7 @@ Expression *evaluateIfBuiltin(InterState *istate, Loc loc,
// But we might need some magic if stack tracing gets added to druntime.
StructLiteralExp *se = ((ClassReferenceExp *)pthis)->value;
assert(arguments->dim <= se->elements->dim);
for (int i = 0; i < arguments->dim; ++i)
for (size_t i = 0; i < arguments->dim; ++i)
{
e = (*arguments)[i]->interpret(istate);
if (exceptionOrCantInterpret(e))
Expand Down
2 changes: 0 additions & 2 deletions src/irstate.c
Expand Up @@ -141,7 +141,6 @@ block *IRState::getContBlock(Identifier *ident)

if (ident)
{
Statement *related = NULL;
block *ret = NULL;
for (bc = this; bc; bc = bc->prev)
{
Expand All @@ -151,7 +150,6 @@ block *IRState::getContBlock(Identifier *ident)
// in many cases will be this same statement).
if (bc->contBlock)
{
related = bc->statement->getRelatedLabeled();
ret = bc->contBlock;
}
if (bc->prev && bc->prev->ident == ident)
Expand Down

0 comments on commit 9180ba2

Please sign in to comment.