tech debt compiler warnings

pull/167/head
Dibyendu Majumdar 6 years ago
parent 7a055dc0c2
commit 471280ca3a

@ -105,8 +105,8 @@ static struct OMRType DoubleType = {
.type = RT_DOUBLE, .return_type = NULL, .bit_size = sizeof(double) * 8};
static struct OMRType PtrType = {
.type = RT_PTR, .return_type = NULL, .bit_size = sizeof(void *) * 8};
static struct OMRType PtrIntType = {
.type = RT_INT64,.return_type = NULL,.bit_size = sizeof(intptr_t) * 8 };
//static struct OMRType PtrIntType = {
// .type = RT_INT64,.return_type = NULL,.bit_size = sizeof(intptr_t) * 8 };
static struct OMRType BadType = {
.type = RT_UNSUPPORTED, .return_type = NULL, .bit_size = 0};
@ -270,6 +270,8 @@ static struct OMRType *sym_struct_type(struct dmr_C *C, struct function *fn,
struct symbol *sym,
struct symbol *sym_node)
{
(void)C;
(void)sym_node;
unsigned int bit_size = 0;
if (sym->bit_size > 0 && sym->bit_size != -1) {
bit_size = sym->bit_size;
@ -281,6 +283,10 @@ static struct OMRType *sym_ptr_type(struct dmr_C *C, struct function *fn,
struct symbol *sym,
struct symbol *sym_node)
{
(void)C;
(void)fn;
(void)sym_node;
(void)sym;
return &PtrType;
}
@ -375,6 +381,7 @@ static JIT_Type check_supported_argtype(struct dmr_C *C, struct symbol *sym)
static struct OMRType *check_supported_returntype(struct dmr_C *C,
struct OMRType *type)
{
(void)C;
if (type->type == RT_AGGREGATE || type->type == RT_FUNCTION ||
type->type == RT_INT || type->type == RT_UNSUPPORTED)
return &BadType;
@ -414,6 +421,7 @@ static JIT_Type map_OMRtype(struct OMRType *type)
static JIT_SymbolRef OMR_alloca(struct function *fn, struct OMRType *type,
int32_t size, bool reg)
{
(void) reg;
JIT_Type omr_type = map_OMRtype(type);
// In OMR there is no explicit alloca IL I believe
// Instead we create a local symbol of appropriate size
@ -431,6 +439,9 @@ static JIT_NodeRef constant_value(struct dmr_C *C, struct function *fn,
struct OMRType *dtype)
{
JIT_NodeRef result = NULL;
(void)C;
(void)fn;
if (dtype->type == RT_INT8) {
result = JIT_ConstInt8((int8_t)val);
@ -460,6 +471,8 @@ static JIT_NodeRef constant_fvalue(struct dmr_C *C, struct function *fn,
{
JIT_NodeRef result = NULL;
(void)C;
(void) fn;
if (dtype->type == RT_DOUBLE) {
result = JIT_ConstDouble(val);
} else if (dtype->type == RT_FLOAT) {
@ -499,6 +512,8 @@ static JIT_SymbolRef build_local(struct dmr_C *C, struct function *fn,
static void build_store(struct dmr_C *C, struct function *fn, JIT_NodeRef v,
JIT_SymbolRef symbol)
{
(void) C;
if (JIT_IsTemporary(fn->injector, symbol)) {
JIT_StoreToTemporary(fn->injector, symbol, v);
}
@ -646,6 +661,9 @@ static JIT_SymbolRef get_sym_value(struct dmr_C *C, struct function *fn,
static JIT_NodeRef val_to_value(struct dmr_C *C, struct function *fn,
long long value, struct symbol *ctype)
{
(void) C;
(void) fn;
switch (ctype->bit_size) {
case 8:
return JIT_ConstInt8((int8_t)value);
@ -703,6 +721,10 @@ static JIT_NodeRef truncate_intvalue(struct dmr_C *C, struct function *fn,
JIT_NodeRef val, struct OMRType *dtype,
int unsigned_cast)
{
(void) C;
(void) fn;
(void) unsigned_cast;
if (JIT_GetNodeType(val) == JIT_Int64 && dtype->bit_size <= 64) {
if (dtype->bit_size == 64)
return val;
@ -915,6 +937,7 @@ static JIT_NodeRef output_op_phi(struct dmr_C *C, struct function *fn,
struct instruction *insn)
{
JIT_SymbolRef ptr = insn->target->priv2;
(void) C;
if (!ptr)
return NULL;
@ -1131,9 +1154,10 @@ static JIT_NodeRef get_operand(struct dmr_C *C, struct function *fn,
bool ptrtoint, bool unsigned_cast)
{
JIT_NodeRef target;
struct OMRType *instruction_type =
get_symnode_or_basetype(C, fn, ctype);
(void)ptrtoint;
(void) unsigned_cast;
if (instruction_type == NULL)
return NULL;
target = pseudo_to_value(C, fn, ctype, pseudo);
@ -1191,7 +1215,7 @@ static JIT_NodeRef output_op_cbr(struct dmr_C *C, struct function *fn,
// Switch to fallthrough block
JIT_SetCurrentBlock(fn->injector, fallthrough_blocknum);
// In the fallthrough block we only need a goto
JIT_NodeRef goto_node = JIT_Goto(fn->injector, false_block);
JIT_Goto(fn->injector, false_block);
return if_node;
}
@ -1200,6 +1224,7 @@ static JIT_NodeRef is_neq_zero(struct dmr_C *C, struct function *fn,
{
JIT_NodeRef cond = NULL;
JIT_Type value_type = JIT_GetNodeType(value);
(void)C;
switch (value_type) {
case JIT_Int32:
cond = JIT_CreateNode2C(OP_icmpne, value,
@ -2160,6 +2185,7 @@ static JIT_NodeRef output_op_ret(struct dmr_C *C, struct function *fn,
static JIT_NodeRef output_op_br(struct dmr_C *C, struct function *fn,
struct instruction *br)
{
(void) C;
JIT_BlockRef target_block = JIT_GetBlock(fn->injector, br->bb_true->nr);
return JIT_Goto(fn->injector, target_block);
}

@ -467,6 +467,7 @@ static struct symbol *restricted_binop_type(struct dmr_C *C, int op,
struct symbol *ltype,
struct symbol *rtype)
{
(void) C;
struct symbol *ctype = NULL;
if (lclass & TYPE_RESTRICT) {
if (rclass & TYPE_RESTRICT) {
@ -561,6 +562,7 @@ Restr:
static inline int lvalue_expression(struct dmr_C *C, struct expression *expr)
{
(void) C;
return expr->type == EXPR_PREOP && expr->op == '*';
}
@ -800,6 +802,7 @@ static void bad_null(struct dmr_C *C, struct expression *expr)
static unsigned long target_qualifiers(struct dmr_C *C, struct symbol *type)
{
(void) C;
unsigned long mod = type->ctype.modifiers & MOD_IGN;
if (type->ctype.base_type && type->ctype.base_type->type == SYM_ARRAY)
mod = 0;
@ -994,6 +997,7 @@ static struct symbol *evaluate_comma(struct dmr_C *C, struct expression *expr)
static int modify_for_unsigned(struct dmr_C *C, int op)
{
(void) C;
if (op == '<')
op = SPECIAL_UNSIGNED_LT;
else if (op == '>')
@ -1591,7 +1595,7 @@ static struct symbol *convert_to_as_mod(struct dmr_C *C, struct symbol *sym, int
{
/* Take the modifiers of the pointer, and apply them to the member */
mod |= sym->ctype.modifiers;
if (sym->ctype.as != as || sym->ctype.modifiers != mod) {
if ((int)(sym->ctype.as) != as || (int)(sym->ctype.modifiers) != mod) {
struct symbol *newsym = dmrC_alloc_symbol(C->S, sym->pos, SYM_NODE);
*newsym = *sym;
newsym->ctype.as = as;
@ -2074,6 +2078,7 @@ static struct symbol *evaluate_member_dereference(struct dmr_C *C, struct expres
static int is_promoted(struct dmr_C *C, struct expression *expr)
{
(void) C;
while (1) {
switch (expr->type) {
case EXPR_BINOP:
@ -2276,6 +2281,7 @@ static void convert_index(struct dmr_C *C, struct expression *e)
static void convert_ident(struct dmr_C *C, struct expression *e)
{
(void) C;
struct expression *child = e->ident_expression;
int offset = e->offset;
@ -2359,7 +2365,7 @@ static struct expression *check_designators(struct dmr_C *C, struct expression *
type = ctype->ctype.base_type;
if (ctype->bit_size >= 0 && type->bit_size >= 0) {
unsigned offset = dmrC_array_element_offset(C->target, type->bit_size, e->idx_to);
if (offset >= ctype->bit_size) {
if (offset >= (unsigned) (ctype->bit_size)) {
err = "index out of bounds in";
break;
}
@ -2425,7 +2431,7 @@ static struct expression *next_designators(struct dmr_C *C, struct expression *o
old->ctype, e, v);
if (!copy) {
n = old->idx_to + 1;
if (dmrC_array_element_offset(C->target, old->ctype->bit_size, n) == ctype->bit_size) {
if ((int)dmrC_array_element_offset(C->target, old->ctype->bit_size, n) == ctype->bit_size) {
convert_index(C, old);
return NULL;
}

@ -381,6 +381,8 @@ Div:
static int simplify_float_cmp(struct dmr_C *C, struct expression *expr, struct symbol *ctype)
{
(void) C;
(void)ctype;
struct expression *left = expr->left, *right = expr->right;
long double l, r;
@ -588,6 +590,7 @@ static int expand_addressof(struct dmr_C *C, struct expression *expr)
static struct expression *constant_symbol_value(struct dmr_C *C, struct symbol *sym, int offset)
{
struct expression *value;
(void)C;
if (sym->ctype.modifiers & (MOD_ASSIGNED | MOD_ADDRESSABLE))
return NULL;
@ -602,9 +605,9 @@ static struct expression *constant_symbol_value(struct dmr_C *C, struct symbol *
continue;
return entry;
}
if (entry->init_offset < offset)
if ((int) entry->init_offset < offset)
continue;
if (entry->init_offset > offset)
if ((int) entry->init_offset > offset)
return NULL;
return entry->init_expr;
} END_FOR_EACH_PTR(entry);
@ -717,6 +720,7 @@ Overflow:
static int simplify_float_preop(struct dmr_C *C, struct expression *expr)
{
(void) C;
struct expression *op = expr->unop;
long double v;
@ -1244,6 +1248,7 @@ static int expand_statement(struct dmr_C *C, struct statement *stmt)
static inline int bad_integer_constant_expression(struct dmr_C *C, struct expression *expr)
{
(void) C;
if (!(expr->flags & Int_const_expr))
return 1;
if (expr->taint & Taint_comma)

@ -495,6 +495,7 @@ static char **handle_switch_M(struct dmr_C *C, char *arg, char **next)
static char **handle_multiarch_dir(struct dmr_C *C, char *arg, char **next)
{
(void)arg;
C->multiarch_dir = *++next;
if (!C->multiarch_dir)
dmrC_die(C, "missing argument for -multiarch-dir option");
@ -603,9 +604,9 @@ static char **handle_onoff_switch(struct dmr_C *C, char *arg, char **next, const
{
int flag = WARNING_ON;
char *p = arg + 1;
unsigned i;
int i;
if (!strcmp(p, "sparse-all")) {
if (strcmp(p, "sparse-all") == 0) {
for (i = 0; i < n; i++) {
if (*warnings[i].flag != WARNING_FORCE_OFF && warnings[i].flag != &C->Wsparse_error)
*warnings[i].flag = WARNING_ON;
@ -847,6 +848,7 @@ static char **handle_switch_s(struct dmr_C *C, char *arg, char **next)
static char **handle_nostdinc(struct dmr_C *C, char *arg, char **next)
{
(void)arg;
dmrC_add_pre_buffer(C, "#nostdinc\n");
return next;
}
@ -860,6 +862,7 @@ static char **handle_switch_n(struct dmr_C *C, char *arg, char **next)
}
static char **handle_base_dir(struct dmr_C *C, char *arg, char **next)
{
(void)arg;
C->gcc_base_dir = *++next;
if (!C->gcc_base_dir)
dmrC_die(C, "missing argument for -gcc-base-dir option");
@ -875,6 +878,9 @@ static char **handle_switch_g(struct dmr_C *C, char *arg, char **next)
}
static char **handle_version(struct dmr_C *C, char *arg, char **next)
{
(void)C;
(void)arg;
(void)next;
printf("%s\n", SPARSE_VERSION);
exit(0);
}
@ -905,8 +911,8 @@ static char **handle_long_options(struct dmr_C *C, char *arg, char **next)
{
static struct switches cmd[] = {
{ "param", handle_param, 1 },
{ "version", handle_version },
{ NULL, NULL }
{ "version", handle_version , 0},
{ NULL, NULL, 0 }
};
struct switches *s = cmd;

@ -771,6 +771,7 @@ static struct basic_block * add_label(struct dmr_C *C, struct entrypoint *ep, st
static void add_branch(struct dmr_C *C, struct entrypoint *ep, struct expression *expr, pseudo_t cond, struct basic_block *bb_true, struct basic_block *bb_false)
{
(void)expr;
struct basic_block *bb = ep->active;
struct instruction *br;
@ -797,15 +798,6 @@ pseudo_t dmrC_alloc_pseudo(struct dmr_C *C, struct instruction *def)
return pseudo;
}
static void clear_symbol_pseudos(struct entrypoint *ep)
{
pseudo_t pseudo;
FOR_EACH_PTR(ep->accesses, pseudo) {
pseudo->sym->pseudo = NULL;
} END_FOR_EACH_PTR(pseudo);
}
static pseudo_t symbol_pseudo(struct dmr_C *C, struct entrypoint *ep, struct symbol *sym)
{
pseudo_t pseudo;
@ -848,7 +840,7 @@ pseudo_t dmrC_value_pseudo(struct dmr_C *C, struct symbol *type, long long val)
int size = type ? type->bit_size : dmrC_value_size(val);
pseudo_t pseudo;
assert(size == -1 || size <= (sizeof(long long) * 8));
assert(size == -1 || size <= (int)(sizeof(long long) * 8));
FOR_EACH_PTR(*list, pseudo) {
if (pseudo->value == val && pseudo->size == size)
@ -947,6 +939,8 @@ struct access_data {
static void finish_address_gen(struct entrypoint *ep, struct access_data *ad)
{
(void)ep;
(void)ad;
}
static int linearize_simple_address(struct dmr_C *C, struct entrypoint *ep,
@ -972,6 +966,7 @@ static int linearize_simple_address(struct dmr_C *C, struct entrypoint *ep,
static struct symbol *base_type(struct dmr_C *C, struct symbol *sym)
{
(void)C;
struct symbol *base = sym;
if (sym) {
@ -1003,6 +998,7 @@ static int linearize_address_gen(struct dmr_C *C, struct entrypoint *ep,
/* Try to get the actual struct type associated with a load or store */
static struct symbol *get_base_symbol_type(struct dmr_C *C, struct access_data *ad) {
(void) C;
struct symbol *orig_type = NULL;
if (ad->address->type == PSEUDO_SYM) {
orig_type = ad->address->sym;
@ -1128,9 +1124,10 @@ static pseudo_t linearize_load_gen(struct dmr_C *C, struct entrypoint *ep, struc
static pseudo_t linearize_access(struct dmr_C *C, struct entrypoint *ep, struct expression *expr)
{
struct access_data ad = { NULL, };
struct access_data ad;
pseudo_t value;
memset(&ad, 0, sizeof ad);
if (!linearize_address_gen(C, ep, expr, &ad))
return VOID_PSEUDO(C);
value = linearize_load_gen(C, ep, &ad);
@ -1141,8 +1138,10 @@ static pseudo_t linearize_access(struct dmr_C *C, struct entrypoint *ep, struct
/* FIXME: FP */
static pseudo_t linearize_inc_dec(struct dmr_C *C, struct entrypoint *ep, struct expression *expr, int postop)
{
struct access_data ad = { NULL, };
pseudo_t old, new, one;
struct access_data ad;
pseudo_t old, new, one;
memset(&ad, 0, sizeof ad);
int op = expr->op == SPECIAL_INCREMENT ? OP_ADD : OP_SUB;
if (!linearize_address_gen(C, ep, expr->unop, &ad))
@ -1265,6 +1264,7 @@ static pseudo_t cast_pseudo(struct dmr_C *C, struct entrypoint *ep, pseudo_t src
static int opcode_sign(struct dmr_C *C, int opcode, struct symbol *ctype)
{
(void)C;
if (ctype && (ctype->ctype.modifiers & MOD_SIGNED)) {
switch(opcode) {
case OP_MULU: case OP_DIVU: case OP_MODU: case OP_LSR:
@ -1295,12 +1295,13 @@ static pseudo_t linearize_expression_to_bool(struct dmr_C *C, struct entrypoint
}
static pseudo_t linearize_assignment(struct dmr_C *C, struct entrypoint *ep, struct expression *expr)
{
struct access_data ad = { NULL, };
struct access_data ad;
struct expression *target = expr->left;
struct expression *src = expr->right;
struct symbol *ctype;
pseudo_t value;
memset(&ad, 0, sizeof ad);
value = linearize_expression(C, ep, src);
if (!target || !linearize_address_gen(C, ep, target, &ad))
return value;
@ -1684,8 +1685,9 @@ static pseudo_t linearize_initializer(struct dmr_C *C, struct entrypoint *ep, st
static void linearize_argument(struct dmr_C *C, struct entrypoint *ep, struct symbol *arg, int nr)
{
struct access_data ad = { NULL, };
struct access_data ad;
memset(&ad, 0, sizeof ad);
ad.source_type = arg;
ad.result_type = arg;
ad.address = symbol_pseudo(C, ep, arg);
@ -1771,9 +1773,10 @@ static pseudo_t linearize_expression(struct dmr_C *C, struct entrypoint *ep, str
static pseudo_t linearize_one_symbol(struct dmr_C *C, struct entrypoint *ep, struct symbol *sym)
{
struct access_data ad = { NULL, };
struct access_data ad;
pseudo_t value;
memset(&ad, 0, sizeof ad);
if (!sym || !sym->initializer || sym->initialized)
return VOID_PSEUDO(C);
@ -1886,10 +1889,11 @@ static void add_asm_input(struct dmr_C *C, struct entrypoint *ep, struct instruc
static void add_asm_output(struct dmr_C *C, struct entrypoint *ep, struct instruction *insn, struct expression *expr,
const char *constraint, const struct ident *ident)
{
struct access_data ad = { NULL, };
struct access_data ad;
pseudo_t pseudo = dmrC_alloc_pseudo(C, insn);
struct asm_constraint *rule;
memset(&ad, 0, sizeof ad);
if (!expr || !linearize_address_gen(C, ep, expr, &ad))
return;
linearize_store_gen(C, ep, pseudo, &ad);
@ -1972,6 +1976,7 @@ static pseudo_t linearize_asm_statement(struct dmr_C *C, struct entrypoint *ep,
static int multijmp_cmp(void *ud, const void *_a, const void *_b)
{
(void) ud;
const struct multijmp *a = (const struct multijmp *)_a;
const struct multijmp *b = (const struct multijmp *)_b;
@ -2470,6 +2475,7 @@ void dmrC_kill_unreachable_bbs(struct dmr_C *C, struct entrypoint *ep)
static int delete_pseudo_user_list_entry(struct dmr_C *C, struct pseudo_user_list **list, pseudo_t *entry, int count)
{
(void)C;
struct pseudo_user *pu;
FOR_EACH_PTR(*list, pu) {

@ -637,6 +637,8 @@ static int SENTINEL_ATTR match_idents(struct dmr_C *C, struct token *token, ...)
{
va_list args;
struct ident * next;
(void) C;
if (dmrC_token_type(token) != TOKEN_IDENT)
return 0;
@ -824,7 +826,8 @@ static void lower_boundary(Num *n, Num *v)
static int type_is_ok(struct dmr_C *C, struct symbol *type, Num *upper, Num *lower)
{
int shift = type->bit_size;
(void) C;
int shift = type->bit_size;
int is_unsigned = type->ctype.modifiers & MOD_UNSIGNED;
if (!is_unsigned)
@ -959,9 +962,9 @@ static struct token *parse_enum_declaration(struct dmr_C *C, struct token *token
base_type = &C->S->bad_ctype;
}
else if (!dmrC_is_int_type(C->S, base_type))
base_type = base_type;
; //base_type = base_type;
else if (type_is_ok(C, base_type, &upper, &lower))
base_type = base_type;
; //base_type = base_type;
else if (type_is_ok(C, &C->S->int_ctype, &upper, &lower))
base_type = &C->S->int_ctype;
else if (type_is_ok(C, &C->S->uint_ctype, &upper, &lower))
@ -1027,6 +1030,8 @@ static struct token *typeof_specifier(struct dmr_C *C, struct token *token, stru
static struct token *ignore_attribute(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) ctx;
(void) attr;
struct expression *expr = NULL;
if (dmrC_match_op(token, '('))
token = dmrC_parens_expression(C, token, &expr, "in attribute");
@ -1035,6 +1040,8 @@ static struct token *ignore_attribute(struct dmr_C *C, struct token *token, stru
static struct token *attribute_packed(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) C;
(void) attr;
if (!ctx->ctype.alignment)
ctx->ctype.alignment = 1;
return token;
@ -1042,6 +1049,7 @@ static struct token *attribute_packed(struct dmr_C *C, struct token *token, stru
static struct token *attribute_aligned(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
int alignment = C->target->max_alignment;
struct expression *expr = NULL;
@ -1053,7 +1061,7 @@ static struct token *attribute_aligned(struct dmr_C *C, struct token *token, str
if (alignment & (alignment-1)) {
dmrC_warning(C, token->pos, "I don't like non-power-of-2 alignments");
return token;
} else if (alignment > ctx->ctype.alignment)
} else if (alignment > (int)ctx->ctype.alignment)
ctx->ctype.alignment = alignment;
return token;
}
@ -1080,6 +1088,7 @@ static struct token *attribute_bitwise(struct dmr_C *C, struct token *token, str
static struct token *attribute_address_space(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
struct expression *expr = NULL;
int as;
token = dmrC_expect_token(C, token, '(', "after address_space attribute");
@ -1145,6 +1154,7 @@ static struct symbol *to_word_mode(struct dmr_C *C, struct symbol *ctype)
static struct token *attribute_mode(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
token = dmrC_expect_token(C, token, '(', "after mode attribute");
if (dmrC_token_type(token) == TOKEN_IDENT) {
struct symbol *mode = dmrC_lookup_keyword(token->ident, NS_KEYWORD);
@ -1161,6 +1171,7 @@ static struct token *attribute_mode(struct dmr_C *C, struct token *token, struct
static struct token *attribute_context(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
struct context *context = (struct context *)dmrC_allocator_allocate(&C->S->context_allocator, 0);
struct expression *args[3];
int argc = 0;
@ -1205,6 +1216,7 @@ static struct token *attribute_context(struct dmr_C *C, struct token *token, str
static struct token *attribute_designated_init(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
if (ctx->ctype.base_type && ctx->ctype.base_type->type == SYM_STRUCT)
ctx->ctype.base_type->designated_init = 1;
else
@ -1214,6 +1226,7 @@ static struct token *attribute_designated_init(struct dmr_C *C, struct token *to
static struct token *attribute_transparent_union(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
if (C->Wtransparent_union)
dmrC_warning(C, token->pos, "attribute __transparent_union__");
if (ctx->ctype.base_type && ctx->ctype.base_type->type == SYM_UNION)
@ -1279,6 +1292,7 @@ static const char *storage_class[] =
static unsigned long storage_modifiers(struct dmr_C *C, struct decl_state *ctx)
{
(void) C;
static unsigned long mod[SMax] =
{
[SAuto] = MOD_AUTO,
@ -1355,12 +1369,14 @@ static struct token *thread_specifier(struct dmr_C *C, struct token *next, struc
static struct token *attribute_force(struct dmr_C *C, struct token *token, struct symbol *attr, struct decl_state *ctx)
{
(void) attr;
set_storage_class(C, &token->pos, ctx, SForced);
return token;
}
static struct token *inline_specifier(struct dmr_C *C, struct token *next, struct decl_state *ctx)
{
(void) C;
ctx->is_inline = 1;
return next;
}
@ -1401,7 +1417,7 @@ static struct token *alignas_specifier(struct dmr_C *C, struct token *token, str
dmrC_warning(C, token->pos, "non-power-of-2 alignment");
return token;
}
if (alignment > ctx->ctype.alignment)
if (alignment > (int)ctx->ctype.alignment)
ctx->ctype.alignment = alignment;
return token;
}
@ -1592,6 +1608,7 @@ static struct token *abstract_array_declarator(struct dmr_C *C, struct token *to
static struct token *skip_attribute(struct dmr_C *C, struct token *token)
{
(void) C;
token = token->next;
if (dmrC_match_op(token, '(')) {
int depth = 1;
@ -1946,6 +1963,7 @@ static struct token *expression_statement(struct dmr_C *C, struct token *token,
static struct token *parse_asm_operands(struct dmr_C *C, struct token *token, struct statement *stmt,
struct expression_list **inout)
{
(void) stmt;
struct expression *expr;
/* Allow empty operands */
@ -1971,6 +1989,7 @@ static struct token *parse_asm_operands(struct dmr_C *C, struct token *token, st
static struct token *parse_asm_clobbers(struct dmr_C *C, struct token *token, struct statement *stmt,
struct expression_list **clobbers)
{
(void) stmt;
struct expression *expr;
do {
@ -1985,7 +2004,7 @@ static struct token *parse_asm_labels(struct dmr_C *C, struct token *token, stru
struct symbol_list **labels)
{
struct symbol *label;
(void) stmt;
do {
token = token->next; /* skip ':' and ',' */
if (dmrC_token_type(token) != TOKEN_IDENT)
@ -2026,6 +2045,7 @@ static struct token *parse_asm_statement(struct dmr_C *C, struct token *token, s
static struct token *parse_asm_declarator(struct dmr_C *C, struct token *token, struct decl_state *ctx)
{
(void) ctx;
struct expression *expr;
token = dmrC_expect_token(C, token, '(', "after asm");
token = dmrC_parse_expression(C, token->next, &expr);
@ -2035,6 +2055,7 @@ static struct token *parse_asm_declarator(struct dmr_C *C, struct token *token,
static struct token *parse_static_assert(struct dmr_C *C, struct token *token, struct symbol_list **unused)
{
(void) unused;
struct expression *cond = NULL, *message = NULL;
token = dmrC_expect_token(C, token->next, '(', "after _Static_assert");
@ -2100,6 +2121,7 @@ static void start_iterator(struct dmr_C *C, struct statement *stmt)
static void end_iterator(struct dmr_C *C, struct statement *stmt)
{
(void) stmt;
dmrC_end_symbol_scope(C);
}
@ -2125,6 +2147,7 @@ static struct statement *start_function(struct dmr_C *C, struct symbol *sym)
static void end_function(struct dmr_C *C, struct symbol *sym)
{
(void) sym;
C->current_fn = NULL;
dmrC_end_function_scope(C);
}
@ -2627,6 +2650,7 @@ struct token *dmrC_initializer(struct dmr_C *C, struct expression **tree, struct
static void declare_argument(struct dmr_C *C, struct symbol *sym, struct symbol *fn)
{
(void) fn;
if (!sym->ident) {
dmrC_sparse_error(C, sym->pos, "no identifier for function argument");
return;

@ -1031,6 +1031,7 @@ static int token_list_different(struct dmr_C *C, struct token *list1, struct tok
static inline void set_arg_count(struct dmr_C *C, struct token *token)
{
(void) C;
dmrC_token_type(token) = TOKEN_ARG_COUNT;
token->count.normal = token->count.quoted =
token->count.str = token->count.vararg = 0;
@ -1139,6 +1140,8 @@ static int try_arg(struct dmr_C *C, struct token *token, enum e_token_type type,
{
struct ident *ident = token->ident;
int nr;
(void) C;
if (!arglist || dmrC_token_type(token) != TOKEN_IDENT)
return 0;
@ -1303,6 +1306,9 @@ static int do_handle_define(struct dmr_C *C, struct stream *stream, struct token
struct ident *name;
int ret;
(void) stream;
(void) line;
if (dmrC_token_type(left) != TOKEN_IDENT) {
dmrC_sparse_error(C, token->pos, "expected identifier to 'define'");
return 1;
@ -1391,6 +1397,9 @@ static int do_handle_undef(struct dmr_C *C, struct stream *stream, struct token
struct token *left = token->next;
struct symbol *sym;
(void) stream;
(void) line;
if (dmrC_token_type(left) != TOKEN_IDENT) {
dmrC_sparse_error(C, token->pos, "expected identifier to 'undef'");
return 1;
@ -1442,6 +1451,8 @@ static int handle_ifdef(struct dmr_C *C, struct stream *stream, struct token **l
{
struct token *next = token->next;
int arg;
(void) line;
if (dmrC_token_type(next) == TOKEN_IDENT) {
arg = token_defined(C, next);
} else {
@ -1457,6 +1468,8 @@ static int handle_ifndef(struct dmr_C *C, struct stream *stream, struct token **
{
struct token *next = token->next;
int arg;
(void) line;
if (dmrC_token_type(next) == TOKEN_IDENT) {
if (!stream->dirty && !stream->ifndef) {
if (!stream->protect) {
@ -1545,6 +1558,8 @@ static int expression_value(struct dmr_C *C, struct token **where)
static int handle_if(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
int value = 0;
(void)line;
if (!C->false_nesting)
value = expression_value(C, &token->next);
@ -1555,6 +1570,8 @@ static int handle_if(struct dmr_C *C, struct stream *stream, struct token **line
static int handle_elif(struct dmr_C *C, struct stream * stream, struct token **line, struct token *token)
{
struct token *top_if = stream->top_if;
(void) line;
end_group(stream);
if (!top_if) {
@ -1588,6 +1605,8 @@ static int handle_elif(struct dmr_C *C, struct stream * stream, struct token **l
static int handle_else(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
struct token *top_if = stream->top_if;
(void) line;
end_group(stream);
if (!top_if) {
@ -1613,6 +1632,8 @@ static int handle_else(struct dmr_C *C, struct stream *stream, struct token **li
static int handle_endif(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
struct token *top_if = stream->top_if;
(void) line;
end_group(stream);
if (!top_if) {
nesting_error(stream);
@ -1628,18 +1649,26 @@ static int handle_endif(struct dmr_C *C, struct stream *stream, struct token **l
static int handle_warning(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) line;
(void) stream;
dmrC_warning(C, token->pos, "%s", show_token_sequence(C, token->next, 0));
return 1;
}
static int handle_error(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) line;
(void) stream;
dmrC_sparse_error(C, token->pos, "%s", show_token_sequence(C, token->next, 0));
return 1;
}
static int handle_nostdinc(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) token;
(void) line;
(void) stream;
/*
* Do we have any non-system includes?
* Clear them out if so..
@ -1717,6 +1746,8 @@ static void add_path_entry(struct dmr_C *C, struct token *token, const char *pat
static int handle_add_include(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) stream;
(void) line;
for (;;) {
token = token->next;
if (dmrC_eof_token(token))
@ -1731,6 +1762,8 @@ static int handle_add_include(struct dmr_C *C, struct stream *stream, struct tok
static int handle_add_isystem(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void)line;
(void)stream;
for (;;) {
token = token->next;
if (dmrC_eof_token(token))
@ -1745,6 +1778,8 @@ static int handle_add_isystem(struct dmr_C *C, struct stream *stream, struct tok
static int handle_add_system(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) line;
(void) stream;
for (;;) {
token = token->next;
if (dmrC_eof_token(token))
@ -1776,6 +1811,8 @@ static void add_dirafter_entry(struct dmr_C *C, struct token *token, const char
static int handle_add_dirafter(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) line;
(void) stream;
for (;;) {
token = token->next;
if (dmrC_eof_token(token))
@ -1790,6 +1827,9 @@ static int handle_add_dirafter(struct dmr_C *C, struct stream *stream, struct to
static int handle_split_include(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) stream;
(void) line;
(void) token;
/*
* -I-
* From info gcc:
@ -1841,11 +1881,17 @@ static int handle_pragma(struct dmr_C *C, struct stream *stream, struct token **
*/
static int handle_line(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) stream;
(void) token;
(void)line;
(void) C;
return 1;
}
static int handle_nondirective(struct dmr_C *C, struct stream *stream, struct token **line, struct token *token)
{
(void) stream;
(void) line;
dmrC_sparse_error(C, token->pos, "unrecognized preprocessor line '%s'", show_token_sequence(C, token, 0));
return 1;
}
@ -1888,13 +1934,13 @@ static void init_preprocessor(struct dmr_C *C)
{ "elif", handle_elif },
};
for (i = 0; i < ARRAY_SIZE(normal); i++) {
for (i = 0; i < (int)ARRAY_SIZE(normal); i++) {
struct symbol *sym;
sym = dmrC_create_symbol(C->S, stream, normal[i].name, SYM_PREPROCESSOR, NS_PREPROCESSOR);
sym->handler = normal[i].handler;
sym->normal = 1;
}
for (i = 0; i < ARRAY_SIZE(special); i++) {
for (i = 0; i < (int)ARRAY_SIZE(special); i++) {
struct symbol *sym;
sym = dmrC_create_symbol(C->S, stream, special[i].name, SYM_PREPROCESSOR, NS_PREPROCESSOR);
sym->handler = special[i].handler;

@ -647,6 +647,7 @@ void ptrlist_sort(struct ptr_list **plist, void *userdata,
}
static int int_cmp(void *ud, const void *_a, const void *_b) {
(void) ud;
const int *a = (const int *)_a;
const int *b = (const int *)_b;
return *a - *b;

@ -51,6 +51,7 @@ void dmrC_init_scope(struct dmr_C *C) {
}
void dmrC_destroy_all_scopes(struct dmr_C *C) {
(void) C;
}
void dmrC_bind_scope(struct dmr_C *C, struct symbol *sym, struct scope *scope)
@ -106,6 +107,7 @@ void dmrC_start_function_scope(struct dmr_C *C)
static void remove_symbol_scope(struct dmr_C *C, struct symbol *sym)
{
(void) C;
struct symbol **ptr = &sym->ident->symbols;
while (*ptr != sym)

@ -156,12 +156,12 @@ const char *dmrC_modifier_string(struct dmr_C *C, unsigned long mod)
{MOD_PURE, "[pure]"},
};
for (i = 0; i < ARRAY_SIZE(mod_names); i++) {
for (i = 0; i < (int) ARRAY_SIZE(mod_names); i++) {
m = mod_names + i;
if (mod & m->mod) {
char c;
const char *name = m->name;
while ((c = *name++) != '\0' && len + 2 < sizeof C->modifier_string_buffer)
while ((c = *name++) != '\0' && len + 2 < (int)(sizeof C->modifier_string_buffer))
C->modifier_string_buffer[len++] = c;
C->modifier_string_buffer[len++] = ' ';
}
@ -178,6 +178,7 @@ static void show_struct_member(struct dmr_C *C, struct symbol *sym)
void dmrC_show_symbol_list(struct dmr_C *C, struct symbol_list *list, const char *sep)
{
(void) sep;
struct symbol *sym;
const char *prepend = "";
@ -195,6 +196,7 @@ struct type_name {
static void FORMAT_ATTR(3) prepend(struct dmr_C *C, struct type_name *name, const char *fmt, ...)
{
(void) C;
static char buffer[512];
int n;
@ -209,6 +211,7 @@ static void FORMAT_ATTR(3) prepend(struct dmr_C *C, struct type_name *name, cons
static void FORMAT_ATTR(3) append(struct dmr_C *C, struct type_name *name, const char *fmt, ...)
{
(void) C;
static char buffer[512];
int n;
@ -785,6 +788,7 @@ static int show_address_gen(struct dmr_C *C, struct expression *expr)
static int show_load_gen(int bits, struct expression *expr, int addr)
{
(void) expr;
int news = new_pseudo();
printf("\tld.%d\t\tv%d,[v%d]\n", bits, news, addr);
@ -793,6 +797,7 @@ static int show_load_gen(int bits, struct expression *expr, int addr)
static void show_store_gen(int bits, int value, struct expression *expr, int addr)
{
(void) expr;
/* FIXME!!! Bitfield store! */
printf("\tst.%d\t\tv%d,[v%d]\n", bits, value, addr);
}
@ -944,6 +949,7 @@ static int show_cast_expr(struct dmr_C *C, struct expression *expr)
static int show_value(struct dmr_C *C, struct expression *expr)
{
(void) C;
int news = new_pseudo();
unsigned long long value = expr->value;
@ -953,6 +959,7 @@ static int show_value(struct dmr_C *C, struct expression *expr)
static int show_fvalue(struct dmr_C *C, struct expression *expr)
{
(void) C;
int news = new_pseudo();
long double value = expr->fvalue;

@ -102,7 +102,7 @@ static void lay_out_union(struct global_symbols_t *S, struct symbol *sym, struct
info->max_align = sym->ctype.alignment;
}
if (sym->bit_size > info->bit_size)
if (sym->bit_size > (int) info->bit_size)
info->bit_size = sym->bit_size;
sym->offset = 0;
@ -258,7 +258,7 @@ static struct symbol *examine_bitfield_type(struct global_symbols_t *S, struct s
if (!base_type)
return sym;
bit_size = base_type->bit_size;
if (sym->bit_size > bit_size)
if (sym->bit_size > (int) bit_size)
dmrC_warning(S->C, sym->pos, "impossible field-width, %d, for this type", sym->bit_size);
alignment = base_type->ctype.alignment;
@ -311,7 +311,7 @@ static int count_array_initializer(struct global_symbols_t *S, struct symbol *t,
count++;
switch (entry->type) {
case EXPR_INDEX:
if (entry->idx_to >= nr)
if ((int)entry->idx_to >= nr)
nr = entry->idx_to+1;
break;
case EXPR_PREOP: {

@ -607,96 +607,99 @@ void dmrC_walk_symbol(struct dmr_C *C, struct symbol *sym,
visitor->end_symbol(visitor->data);
}
static void begin_symbol_default(void *data, struct symbol_info *syminfo) {}
static void end_symbol_default(void *data) {}
static void begin_members_default(void *data, struct symbol_info *syminfo) {}
static void end_members_default(void *data) {}
static void begin_arguments_default(void *data, struct symbol_info *syminfo) {}
static void end_arguments_default(void *data) {}
static void reference_symbol_default(void *data, uint64_t id, const char *name) {}
static void begin_body_default(void *data, struct symbol_info *syminfo) {}
static void end_body_default(void *data) {}
static void begin_symbol_default(void *data, struct symbol_info *syminfo) {(void)data; (void)syminfo;}
static void end_symbol_default(void *data) {(void)data;}
static void begin_members_default(void *data, struct symbol_info *syminfo) {(void)data; (void)syminfo;}
static void end_members_default(void *data) {(void)data;}
static void begin_arguments_default(void *data, struct symbol_info *syminfo) {(void)data; (void)syminfo;}
static void end_arguments_default(void *data) {(void)data;}
static void reference_symbol_default(void *data, uint64_t id, const char *name) {(void)data; (void)id; (void)name;}
static void begin_body_default(void *data, struct symbol_info *syminfo) {(void)data; (void)syminfo;}
static void end_body_default(void *data) {(void)data;}
static void begin_func_returntype_default(void *data,
struct symbol_info *syminfo)
{
(void)data; (void)syminfo;
}
static void end_func_returntype_default(void *data)
{
(void)data;
}
static void begin_basetype_default(void *data, struct symbol_info *syminfo) {}
static void end_basetype_default(void *data) {}
static void begin_basetype_default(void *data, struct symbol_info *syminfo) {(void)data; (void)syminfo;}
static void end_basetype_default(void *data) {(void)data;}
static void begin_initializer_default(void *data, struct symbol_info *syminfo)
{
(void)data; (void)syminfo;
}
static void end_initializer_default(void *data) {}
static void string_expression_default(void *data, const char *str) {}
static void int_literal_default(void *data, long long value, int bit_size, bool is_unsigned) {}
static void float_literal_default(void *data, long double fvalue, int bit_size) {}
static void begin_statement_default(void *data, enum statement_type statement_type) {}
static void end_statement_default(void *data) {}
static void begin_expression_default(void *data, enum expression_type expr_type) {}
static void end_expression_default(void *data) {}
static void begin_assignment_expression_default(void *data, enum expression_type expr_type, int op) {}
static void end_assignment_expression_default(void *data) {}
static void begin_binop_expression_default(void *data, enum expression_type expr_type, int op) {}
static void end_binop_expression_default(void *data) {}
static void end_initializer_default(void *data) {(void)data;}
static void string_expression_default(void *data, const char *str) {(void)data; (void)str;}
static void int_literal_default(void *data, long long value, int bit_size, bool is_unsigned) {(void)data; (void)value; (void) bit_size; (void) is_unsigned;}
static void float_literal_default(void *data, long double fvalue, int bit_size) {(void)data; (void) fvalue; (void)bit_size;}
static void begin_statement_default(void *data, enum statement_type statement_type) {(void)data; (void)statement_type;}
static void end_statement_default(void *data) {(void)data;}
static void begin_expression_default(void *data, enum expression_type expr_type) {(void)data; (void)expr_type;}
static void end_expression_default(void *data) {(void)data;}
static void begin_assignment_expression_default(void *data, enum expression_type expr_type, int op) {(void)data; (void) expr_type; (void) op;}
static void end_assignment_expression_default(void *data) {(void) data;}
static void begin_binop_expression_default(void *data, enum expression_type expr_type, int op) {(void)data; (void)expr_type; (void)op;}
static void end_binop_expression_default(void *data) {(void)data;}
static void begin_preop_expression_default(void *data,
enum expression_type expr_type, int op) {}
static void end_preop_expression_default(void *data) {}
enum expression_type expr_type, int op) {(void)data; (void)expr_type; (void)op;}
static void end_preop_expression_default(void *data) {(void)data;}
static void begin_postop_expression_default(void *data,
enum expression_type expr_type, int op) {}
static void end_postop_expression_default(void *data) {}
enum expression_type expr_type, int op) {(void)data; (void)expr_type; (void)op;}
static void end_postop_expression_default(void *data) {(void)data;}
static void begin_direct_call_expression_default(void *data,
enum expression_type expr_type, const char *name) {}
enum expression_type expr_type, const char *name) {(void)data; (void)expr_type; (void) name;}
static void begin_indirect_call_expression_default(void *data,
enum expression_type expr_type) {}
static void end_call_expression_default(void *data) {}
enum expression_type expr_type) {(void)data; (void)expr_type;}
static void end_call_expression_default(void *data) {(void)data;}
static void begin_callarg_expression_default(void *data,
enum expression_type expr_type,
int argpos) {}
static void end_callarg_expression_default(void *data) {}
int argpos) {(void)data; (void)expr_type; (void)argpos;}
static void end_callarg_expression_default(void *data) {(void)data;}
static void begin_cast_expression_default(void *data,
enum expression_type expr_type,
int oldbits, int newbits,
bool is_unsigned) {}
static void end_cast_expression_default(void *data) {}
static void begin_conditional_expression_default(void *data, enum expression_type expr_type) {}
static void end_conditional_expression_default(void *data) {}
static void begin_label_expression_default(void *data, enum expression_type expr_type) {}
static void end_label_expression_default(void *data) {}
bool is_unsigned) {(void)data; (void)expr_type; (void)oldbits; (void)newbits; (void)is_unsigned;}
static void end_cast_expression_default(void *data) {(void)data;}
static void begin_conditional_expression_default(void *data, enum expression_type expr_type) {(void)data; (void) expr_type;}
static void end_conditional_expression_default(void *data) {(void)data;}
static void begin_label_expression_default(void *data, enum expression_type expr_type) {(void)data; (void)expr_type;}
static void end_label_expression_default(void *data) {(void)data;}
static void do_expression_identifier_default(void *data,
enum expression_type expr_type, const char *ident) {}
enum expression_type expr_type, const char *ident) {(void)data; (void)expr_type; (void) ident;}
static void do_expression_index_default(void *data,
enum expression_type expr_type, unsigned from, unsigned to) {}
enum expression_type expr_type, unsigned from, unsigned to) {(void)data; (void)expr_type; (void) from; (void) to;}
static void begin_expression_position_default(void *data,
enum expression_type expr_type, unsigned init_offset, int bit_offset, const char *ident) {}
static void end_expression_position_default(void *data) {}
enum expression_type expr_type, unsigned init_offset, int bit_offset, const char *ident) {(void)data; (void)expr_type; (void) init_offset; (void) ident; (void)bit_offset;}
static void end_expression_position_default(void *data) {(void)data;}
static void begin_initialization_default(void *data,
enum expression_type expr_type) {}
static void end_initialization_default(void *data) {}
static void begin_label_default(void *data, const char *name) {}
static void end_label_default(void *data) {}
static void begin_iterator_prestatement_default(void *data) {}
static void end_iterator_prestatement_default(void *data) {}
static void begin_iterator_precondition_default(void *data) {}
static void end_iterator_precondition_default(void *data) {}
static void begin_iterator_statement_default(void *data) {}
static void end_iterator_statement_default(void *data) {}
static void begin_iterator_postcondition_default(void *data) {}
static void end_iterator_postcondition_default(void *data) {}
static void begin_iterator_poststatement_default(void *data) {}
static void end_iterator_poststatement_default(void *data) {}
static void begin_case_value_default(void *data, long long value) {}
static void begin_case_range_default(void *data, long long from, long long to) {}
static void begin_default_case_default(void *data) {}
static void end_case_default(void *data) {}
static void begin_if_then_default(void *data) {}
static void end_if_then_default(void *data) {}
static void begin_if_else_default(void *data) {}
static void end_if_else_default(void *data) {}
enum expression_type expr_type) {(void)data; (void)expr_type;}
static void end_initialization_default(void *data) {(void)data;}
static void begin_label_default(void *data, const char *name) {(void)data; (void) name;}
static void end_label_default(void *data) {(void)data;}
static void begin_iterator_prestatement_default(void *data) {(void)data;}
static void end_iterator_prestatement_default(void *data) {(void)data;}
static void begin_iterator_precondition_default(void *data) {(void)data;}
static void end_iterator_precondition_default(void *data) {(void)data;}
static void begin_iterator_statement_default(void *data) {(void)data;}
static void end_iterator_statement_default(void *data) {(void)data;}
static void begin_iterator_postcondition_default(void *data) {(void)data;}
static void end_iterator_postcondition_default(void *data) {(void)data;}
static void begin_iterator_poststatement_default(void *data) {(void)data;}
static void end_iterator_poststatement_default(void *data) {(void)data;}
static void begin_case_value_default(void *data, long long value) {(void)data; (void)value;}
static void begin_case_range_default(void *data, long long from, long long to) {(void)data; (void)from; (void)to;}
static void begin_default_case_default(void *data) {(void)data;}
static void end_case_default(void *data) {(void)data;}
static void begin_if_then_default(void *data) {(void)data;}
static void end_if_then_default(void *data) {(void)data;}
static void begin_if_else_default(void *data) {(void)data;}
static void end_if_else_default(void *data) {(void)data;}
void dmrC_init_symbol_visitor(struct symbol_visitor *visitor)

@ -1162,7 +1162,6 @@ static void constructor (LexState *ls, expdesc *t) {
* be anchored somewhere else by the time parsing finishes
*/
static TString *user_defined_type_name(LexState *ls, TString *typename) {
char buffer[128];
size_t len = 0;
if (testnext(ls, '.')) {
char buffer[128] = { 0 };

@ -685,7 +685,6 @@ static struct ast_node *parse_table_constructor(struct parser_state *parser) {
* be anchored somewhere else by the time parsing finishes
*/
static TString *user_defined_type_name(LexState *ls, TString *typename) {
char buffer[128];
size_t len = 0;
if (testnext(ls, '.')) {
char buffer[128] = { 0 };
@ -766,7 +765,7 @@ static bool parse_parameter_list(struct parser_state *parser, struct lua_symbol_
int nparams = 0;
bool is_vararg = false;
enum { N = MAXVARS + 10 };
int vars[N] = { 0 };
//int vars[N] = { 0 };
TString *typenames[N] = { NULL };
if (ls->t.token != ')') { /* is 'parlist' not empty? */
do {
@ -825,7 +824,6 @@ static int parse_expression_list(struct parser_state *parser, struct ast_node_li
/* parse function arguments */
static struct ast_node *parse_function_call(struct parser_state *parser, TString *methodname, int line) {
LexState *ls = parser->ls;
int base, nparams;
struct ast_node *call_expr = dmrC_allocator_allocate(&parser->container->ast_node_allocator, 0);
call_expr->type = AST_FUNCTION_CALL_EXPR;
call_expr->function_call_expr.methodname = methodname;
@ -1081,7 +1079,6 @@ static struct ast_node *parse_sub_expression(struct parser_state *parser, int li
struct ast_node *expr = NULL;
uop = get_unary_opr(ls->t.token);
if (uop != OPR_NOUNOPR) {
int line = ls->linenumber;
// RAVI change - get usertype if @<name>
TString *usertype = NULL;
if (uop == OPR_TO_TYPE) {
@ -1108,7 +1105,6 @@ static struct ast_node *parse_sub_expression(struct parser_state *parser, int li
op = get_binary_opr(ls->t.token);
while (op != OPR_NOBINOPR && priority[op].left > limit) {
BinOpr nextop;
int line = ls->linenumber;
luaX_next(ls);
/* read sub-expression with higher priority */
struct ast_node *exprright = parse_sub_expression(parser, priority[op].right, &nextop);
@ -1163,9 +1159,7 @@ static struct ast_node *parse_condition(struct parser_state *parser) {
static struct ast_node *parse_goto_statment(struct parser_state *parser) {
LexState *ls = parser->ls;
int line = ls->linenumber;
TString *label;
int g;
if (testnext(ls, TK_GOTO))
label = check_name_and_next(ls);
else {
@ -1196,6 +1190,7 @@ static struct ast_node *generate_label(struct parser_state *parser, TString *lab
}
static struct ast_node *parse_label_statement(struct parser_state *parser, TString *label, int line) {
(void) line;
LexState *ls = parser->ls;
/* label -> '::' NAME '::' */
checknext(ls, TK_DBCOLON); /* skip double colon */
@ -1245,6 +1240,9 @@ static struct ast_node *parse_repeat_statement(struct parser_state *parser, int
* called by fornum(), forlist()
*/
static void parse_forbody(struct parser_state *parser, struct ast_node* stmt, int line, int nvars, int isnum) {
(void) line;
(void) nvars;
(void) isnum;
LexState *ls = parser->ls;
/* forbody -> DO block */
checknext(ls, TK_DO);
@ -1330,9 +1328,9 @@ static struct ast_node *parse_for_statement(struct parser_state *parser, int lin
/* parse if cond then block - called from ifstat() */
static struct ast_node *parse_if_cond_then_block(struct parser_state *parser, int *escapelist) {
(void) escapelist;
LexState *ls = parser->ls;
/* test_then_block -> [IF | ELSEIF] cond THEN block */
int jf; /* instruction to skip 'then' code (if condition is false) */
luaX_next(ls); /* skip IF or ELSEIF */
struct ast_node *test_then_block = dmrC_allocator_allocate(&parser->container->ast_node_allocator, 0);
test_then_block->type = AST_NONE; // This is not an AST node on its own
@ -1407,7 +1405,7 @@ static struct ast_node *parse_local_statement(struct parser_state *parser) {
* instead.
*/
enum { N = MAXVARS + 10 };
int vars[N] = { 0 };
//int vars[N] = { 0 };
TString *usertypes[N] = { NULL };
struct ast_node *node = dmrC_allocator_allocate(&parser->container->ast_node_allocator, 0);
node->type = AST_LOCAL_STMT;
@ -2120,14 +2118,13 @@ static void checkmode(lua_State *L, const char *mode, const char *x) {
}
}
static int ravi_f_parser(lua_State *L, void *ud) {
LClosure *cl;
static void ravi_f_parser(lua_State *L, void *ud) {
struct SParser *p = cast(struct SParser *, ud);
lua_lock(L); // Workaroud for zgetc() which assumes lua_lock()
int c = zgetc(p->z); /* read first character */
lua_unlock(L);
checkmode(L, p->mode, "text");
return parse_to_ast(L, p->z, &p->buff, p->name, c);
parse_to_ast(L, p->z, &p->buff, p->name, c);
}
static int protected_ast_builder(lua_State *L, ZIO *z, const char *name,
@ -2232,7 +2229,7 @@ static int build_ast(lua_State *L) {
size_t l;
const char *s = lua_tolstring(L, 1, &l);
const char *mode = luaL_optstring(L, 3, "bt");
int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */
//int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */
if (s != NULL) { /* loading a string? */
const char *chunkname = luaL_optstring(L, 2, s);
status = build_ast_from_buffer(L, s, l, chunkname, mode);

@ -69,6 +69,7 @@ static void pop_tabindex(struct parser_state *S) {
}
static void *visited(struct parser_state *S, int id) {
(void) S;
return (void *)(intptr_t)id;
}
@ -87,13 +88,6 @@ static void newNumProp(struct parser_state *S, const char *name, intptr_t value)
lua_settable(S->L, -3);
}
static void newIdProp(struct parser_state *S, const char *name,
unsigned int id) {
char buf[256];
snprintf(buf, 256, "_%d", id);
newProp(S, name, buf);
}
static void popNamedTable(struct parser_state *S, const char *name) {
lua_assert(lua_istable(S->L, -1));
lua_assert(lua_istable(S->L, -2));
@ -188,7 +182,7 @@ static void examine_modifiers(struct parser_state *S, struct symbol *sym) {
if (sym->ns != NS_SYMBOL) return;
for (int i = 0; i < ARRAY_SIZE(mod_names); i++) {
for (int i = 0; i < (int)ARRAY_SIZE(mod_names); i++) {
m = mod_names + i;
if (sym->ctype.modifiers & m->mod) { newNumProp(S, m->name, 1); }
}
@ -324,12 +318,6 @@ static int get_stream_id(struct dmr_C *C, const char *name) {
return -1;
}
static void clean_up_symbols(struct dmr_C *C, struct symbol_list *list) {
struct symbol *sym;
FOR_EACH_PTR(list, sym) { dmrC_expand_symbol(C, sym); }
END_FOR_EACH_PTR(sym);
}
static void examine_symbol_list(struct parser_state *S, int stream_id,
struct symbol_list *list) {
@ -351,7 +339,6 @@ TODO: allow Lua/Ravi to specify additional command line parameters.
static int dmrC_getsymbols(lua_State *L) {
struct symbol_list *symlist;
struct string_list *filelist = NULL;
char *file;
struct dmr_C *C = new_dmr_C();
@ -360,8 +347,6 @@ static int dmrC_getsymbols(lua_State *L) {
int argc = 0;
symlist = dmrC_sparse_initialize(C, argc, argv, &filelist);
// Simplification
// clean_up_symbols(C, symlist);
struct parser_state parser_state = {
.L = L, .C = C, .idcount = 1, .stack = {0}, .stackpos = -1, .tabidx = 1};

@ -777,7 +777,7 @@ static void emit_gettable_ai(struct function *fn, int A, int B,
membuff_add_string(&fn->body, " goto Lraise_error;\n");
#else
membuff_add_fstring(&fn->body, " raise_error(L, %d);\n", Error_array_out_of_bounds);
#endif`
#endif
membuff_add_string(&fn->body, "}\n");
}
@ -899,6 +899,7 @@ static void emit_settable_af(struct function *fn, int A, int B,
static void emit_op_arithslow(struct function *fn, int A, int B, int C, OpCode op, int pc,
const char *opchar, const char *numop, const char *tm) {
(void)pc;
(void)op;
emit_reg(fn, "ra", A);
emit_reg_or_k(fn, "rb", B);
emit_reg_or_k(fn, "rc", C);

@ -69,7 +69,7 @@ void raviV_dumpIR(struct lua_State *L, struct Proto *p) {
// and also whether to dump header or body or both
char fname[30];
snprintf(fname, sizeof fname, "jitfunction");
ravi_compile_options_t options = {0};
ravi_compile_options_t options = {0, 0, 0};
options.codegen_type = RAVI_CODEGEN_ALL;
if (raviJ_codegen(L, p, &options, fname, &buf)) { puts(buf.buf); }
membuff_free(&buf);

@ -198,7 +198,8 @@ void raviV_dumpIR(struct lua_State *L, struct Proto *p) {
char fname[30];
snprintf(fname, sizeof fname, "%s", "jit_function");
ravi_compile_options_t options = { 0 };
ravi_compile_options_t options;
memset(&options, 0, sizeof options);
options.codegen_type = RAVI_CODEGEN_ALL;
if (raviJ_codegen(L, p, &options, fname, &buf)) {
printf("%s", buf.buf);
@ -213,36 +214,42 @@ void raviV_dumpASM(struct lua_State *L, struct Proto *p) {
}
void raviV_setminexeccount(lua_State *L, int value) {
(void)value;
global_State *G = G(L);
if (!G->ravi_state) return;
// G->ravi_state->jit->min_exec_count_ = value;
}
int raviV_getminexeccount(lua_State *L) {
global_State *G = G(L);
(void)L;
//global_State *G = G(L);
// if (!G->ravi_state)
return 0;
// return G->ravi_state->jit->min_exec_count_;
}
void raviV_setmincodesize(lua_State *L, int value) {
(void)value;
global_State *G = G(L);
if (!G->ravi_state) return;
// G->ravi_state->jit->min_code_size_ = value;
}
int raviV_getmincodesize(lua_State *L) {
global_State *G = G(L);
(void)L;
//global_State *G = G(L);
// if (!G->ravi_state)
return 0;
// return G->ravi_state->jit->min_code_size_;
}
void raviV_setauto(lua_State *L, int value) {
(void)value;
global_State *G = G(L);
if (!G->ravi_state) return;
// G->ravi_state->jit->auto_ = value;
}
int raviV_getauto(lua_State *L) {
global_State *G = G(L);
(void)L;
//global_State *G = G(L);
// if (!G->ravi_state)
return 0;
// return G->ravi_state->jit->auto_;
@ -250,6 +257,7 @@ int raviV_getauto(lua_State *L) {
// Turn on/off the JIT compiler
void raviV_setjitenabled(lua_State *L, int value) {
(void)value;
global_State *G = G(L);
if (!G->ravi_state) return;
// G->ravi_state->jit->enabled_ = value;
@ -261,12 +269,14 @@ int raviV_getjitenabled(lua_State *L) {
}
void raviV_setoptlevel(lua_State *L, int value) {
(void)value;
global_State *G = G(L);
if (!G->ravi_state) return;
// G->ravi_state->jit->opt_level_ = value;
}
int raviV_getoptlevel(lua_State *L) {
global_State *G = G(L);
(void)L;
//global_State *G = G(L);
// if (!G->ravi_state)
return 0;
// return G->ravi_state->jit->opt_level_;

@ -336,7 +336,7 @@ int main()
{
int failures = 0;
failures += test_asmvm();
// failures += test_vm();
//failures += test_vm();
if (failures)
printf("FAILED\n");
else

@ -1009,7 +1009,8 @@ void json_value_free_ex (json_settings * settings, json_value * value)
void json_value_free (json_value * value)
{
json_settings settings = { 0 };
json_settings settings;
memset(&settings, 0, sizeof settings);
settings.mem_free = default_free;
json_value_free_ex (&settings, value);
}

Loading…
Cancel
Save