Added gcc option '-Wconversion'

No warnings for standard numerical types. Still pending alternative
numerical types.
This commit is contained in:
Roberto Ierusalimschy
2024-07-27 13:32:59 -03:00
parent 15231d4fb2
commit 0acd55898d
44 changed files with 398 additions and 359 deletions

34
lcode.c
View File

@@ -335,7 +335,7 @@ static void savelineinfo (FuncState *fs, Proto *f, int line) {
}
luaM_growvector(fs->ls->L, f->lineinfo, pc, f->sizelineinfo, ls_byte,
INT_MAX, "opcodes");
f->lineinfo[pc] = linedif;
f->lineinfo[pc] = cast(ls_byte, linedif);
fs->previousline = line; /* last line saved */
}
@@ -409,7 +409,7 @@ int luaK_codevABCk (FuncState *fs, OpCode o, int A, int B, int C, int k) {
/*
** Format and emit an 'iABx' instruction.
*/
int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bc) {
int luaK_codeABx (FuncState *fs, OpCode o, int A, int Bc) {
lua_assert(getOpMode(o) == iABx);
lua_assert(A <= MAXARG_A && Bc <= MAXARG_Bx);
return luaK_code(fs, CREATE_ABx(o, A, Bc));
@@ -420,7 +420,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bc) {
** Format and emit an 'iAsBx' instruction.
*/
static int codeAsBx (FuncState *fs, OpCode o, int A, int Bc) {
unsigned int b = cast_uint(Bc) + OFFSET_sBx;
int b = Bc + OFFSET_sBx;
lua_assert(getOpMode(o) == iAsBx);
lua_assert(A <= MAXARG_A && b <= MAXARG_Bx);
return luaK_code(fs, CREATE_ABx(o, A, b));
@@ -431,7 +431,7 @@ static int codeAsBx (FuncState *fs, OpCode o, int A, int Bc) {
** Format and emit an 'isJ' instruction.
*/
static int codesJ (FuncState *fs, OpCode o, int sj, int k) {
unsigned int j = cast_uint(sj) + OFFSET_sJ;
int j = sj + OFFSET_sJ;
lua_assert(getOpMode(o) == isJ);
lua_assert(j <= MAXARG_sJ && (k & ~1) == 0);
return luaK_code(fs, CREATE_sJ(o, j, k));
@@ -483,7 +483,7 @@ void luaK_checkstack (FuncState *fs, int n) {
*/
void luaK_reserveregs (FuncState *fs, int n) {
luaK_checkstack(fs, n);
fs->freereg += n;
fs->freereg = cast_byte(fs->freereg + n);
}
@@ -1290,25 +1290,25 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
luaK_exp2anyreg(fs, t); /* put it in a register */
if (t->k == VUPVAL) {
int temp = t->u.info; /* upvalue index */
lu_byte temp = cast_byte(t->u.info); /* upvalue index */
lua_assert(isKstr(fs, k));
t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
t->u.ind.idx = k->u.info; /* literal short string */
t->u.ind.idx = cast(short, k->u.info); /* literal short string */
t->k = VINDEXUP;
}
else {
/* register index of the table */
t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info);
if (isKstr(fs, k)) {
t->u.ind.idx = k->u.info; /* literal short string */
t->u.ind.idx = cast(short, k->u.info); /* literal short string */
t->k = VINDEXSTR;
}
else if (isCint(k)) {
t->u.ind.idx = cast_int(k->u.ival); /* int. constant in proper range */
else if (isCint(k)) { /* int. constant in proper range? */
t->u.ind.idx = cast(short, k->u.ival);
t->k = VINDEXI;
}
else {
t->u.ind.idx = luaK_exp2anyreg(fs, k); /* register */
t->u.ind.idx = cast(short, luaK_exp2anyreg(fs, k)); /* register */
t->k = VINDEXED;
}
}
@@ -1623,7 +1623,7 @@ void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) {
luaK_dischargevars(fs, e);
switch (opr) {
case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */
if (constfolding(fs, opr + LUA_OPUNM, e, &ef))
if (constfolding(fs, cast_int(opr + LUA_OPUNM), e, &ef))
break;
/* else */ /* FALLTHROUGH */
case OPR_LEN:
@@ -1711,7 +1711,7 @@ static void codeconcat (FuncState *fs, expdesc *e1, expdesc *e2, int line) {
void luaK_posfix (FuncState *fs, BinOpr opr,
expdesc *e1, expdesc *e2, int line) {
luaK_dischargevars(fs, e2);
if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2))
if (foldbinop(opr) && constfolding(fs, cast_int(opr + LUA_OPADD), e1, e2))
return; /* done by folding */
switch (opr) {
case OPR_AND: {
@@ -1797,11 +1797,11 @@ void luaK_fixline (FuncState *fs, int line) {
void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize) {
Instruction *inst = &fs->f->code[pc];
int rb = (hsize != 0) ? luaO_ceillog2(hsize) + 1 : 0; /* hash size */
int extra = asize / (MAXARG_vC + 1); /* higher bits of array size */
int rc = asize % (MAXARG_vC + 1); /* lower bits of array size */
int k = (extra > 0); /* true iff needs extra argument */
*inst = CREATE_vABCk(OP_NEWTABLE, ra, rb, rc, k);
hsize = (hsize != 0) ? luaO_ceillog2(cast_uint(hsize)) + 1 : 0;
*inst = CREATE_vABCk(OP_NEWTABLE, ra, hsize, rc, k);
*(inst + 1) = CREATE_Ax(OP_EXTRAARG, extra);
}
@@ -1825,7 +1825,7 @@ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
luaK_codevABCk(fs, OP_SETLIST, base, tostore, nelems, 1);
codeextraarg(fs, extra);
}
fs->freereg = base + 1; /* free registers with list values */
fs->freereg = cast_byte(base + 1); /* free registers with list values */
}