Skip to content

Commit

Permalink
py, unix: Allow to compile with -Wunused-parameter.
Browse files Browse the repository at this point in the history
See issue #699.
  • Loading branch information
dpgeorge committed Jan 20, 2015
1 parent 50912e7 commit ff8dd3f
Show file tree
Hide file tree
Showing 51 changed files with 156 additions and 19 deletions.
1 change: 1 addition & 0 deletions extmod/modubinascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#if MICROPY_PY_UBINASCII

STATIC mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);

Expand Down
2 changes: 2 additions & 0 deletions extmod/moductypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ STATIC NORETURN void syntax_error(void) {
}

STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)n_kw;
if (n_args < 2 || n_args > 3) {
syntax_error();
}
Expand All @@ -137,6 +138,7 @@ STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_u
}

STATIC void uctypes_struct_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_uctypes_struct_t *self = self_in;
const char *typen = "unk";
if (MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) {
Expand Down
1 change: 1 addition & 0 deletions extmod/moduhashlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ STATIC mp_obj_t hash_digest(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(hash_digest_obj, hash_digest);

STATIC mp_obj_t hash_hexdigest(mp_obj_t self_in) {
(void)self_in;
mp_not_implemented("");
#if 0
mp_obj_hash_t *self = self_in;
Expand Down
4 changes: 4 additions & 0 deletions extmod/modure.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef struct _mp_obj_match_t {


STATIC void match_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_match_t *self = self_in;
print(env, "<match num=%d @%p>", self->num_matches);
}
Expand Down Expand Up @@ -82,11 +83,13 @@ STATIC const mp_obj_type_t match_type = {
};

STATIC void re_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_re_t *self = self_in;
print(env, "<re %p>", self);
}

STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
(void)n_args;
mp_obj_re_t *self = args[0];
Subject subj;
mp_uint_t len;
Expand Down Expand Up @@ -192,6 +195,7 @@ STATIC mp_obj_t mod_re_compile(uint n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile);

STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
(void)n_args;
mp_obj_re_t *self = mod_re_compile(1, args);

const mp_obj_t args2[] = {self, args[1]};
Expand Down
1 change: 1 addition & 0 deletions extmod/moduzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ STATIC int mod_uzlib_grow_buf(TINF_DATA *d, unsigned alloc_req) {
}

STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;
mp_obj_t data = args[0];
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
Expand Down
1 change: 1 addition & 0 deletions py/asmx86.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void asm_x86_start_pass(asm_x86_t *as, mp_uint_t pass) {
}

void asm_x86_end_pass(asm_x86_t *as) {
(void)as;
}

// all functions must go through this one to emit bytes
Expand Down
2 changes: 2 additions & 0 deletions py/builtinevex.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_t globals, mp_obj_t loc
}

STATIC mp_obj_t mp_builtin_compile(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;

// get the source
mp_uint_t str_len;
const char *str = mp_obj_str_get_data(args[0], &str_len);
Expand Down
7 changes: 5 additions & 2 deletions py/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3210,6 +3210,9 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
EMIT_ARG(store_id, MP_QSTR___doc__);
}
}
#else
(void)comp;
(void)pn;
#endif
}

Expand Down Expand Up @@ -3514,7 +3517,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
}
#endif

STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
STATIC void scope_compute_things(scope_t *scope) {
#if !MICROPY_EMIT_CPYTHON
// in Micro Python we put the *x parameter after all other parameters (except **y)
if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) {
Expand Down Expand Up @@ -3678,7 +3681,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is

// compute some things related to scope and identifiers
for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) {
compile_scope_compute_things(comp, s);
scope_compute_things(s);
}

// finish with pass 1
Expand Down
12 changes: 12 additions & 0 deletions py/emitbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ STATIC void emit_write_bytecode_byte_signed_label(emit_t* emit, byte b1, mp_uint
}

STATIC void emit_bc_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) {
(void)emit;
(void)op;
(void)arg1;
(void)arg2;
}

STATIC void emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
Expand Down Expand Up @@ -499,6 +503,7 @@ STATIC void emit_bc_load_null(emit_t *emit) {
};

STATIC void emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
assert(local_num >= 0);
emit_bc_pre(emit, 1);
if (local_num <= 15) {
Expand All @@ -509,11 +514,13 @@ STATIC void emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
}

STATIC void emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
emit_bc_pre(emit, 1);
emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_DEREF, local_num);
}

STATIC void emit_bc_load_name(emit_t *emit, qstr qst) {
(void)qst;
emit_bc_pre(emit, 1);
emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_NAME, qst);
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
Expand All @@ -522,6 +529,7 @@ STATIC void emit_bc_load_name(emit_t *emit, qstr qst) {
}

STATIC void emit_bc_load_global(emit_t *emit, qstr qst) {
(void)qst;
emit_bc_pre(emit, 1);
emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_GLOBAL, qst);
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
Expand Down Expand Up @@ -553,6 +561,7 @@ STATIC void emit_bc_load_subscr(emit_t *emit) {
}

STATIC void emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
assert(local_num >= 0);
emit_bc_pre(emit, -1);
if (local_num <= 15) {
Expand All @@ -563,6 +572,7 @@ STATIC void emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
}

STATIC void emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
emit_bc_pre(emit, -1);
emit_write_bytecode_byte_uint(emit, MP_BC_STORE_DEREF, local_num);
}
Expand Down Expand Up @@ -591,10 +601,12 @@ STATIC void emit_bc_store_subscr(emit_t *emit) {
}

STATIC void emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_FAST, local_num);
}

STATIC void emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
(void)qst;
emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_DEREF, local_num);
}

Expand Down
2 changes: 2 additions & 0 deletions py/emitglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
fwrite(fun_data, fun_len, 1, fp_write_code);
fclose(fp_write_code);
#endif
#else
(void)fun_len;
#endif
}
#endif
Expand Down
38 changes: 33 additions & 5 deletions py/emitnative.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
}

STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
(void)emit;
(void)source_line;
}

/*
Expand Down Expand Up @@ -905,6 +907,7 @@ STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int reg
}

STATIC void emit_post(emit_t *emit) {
(void)emit;
}

STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
Expand Down Expand Up @@ -1247,6 +1250,9 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
// not implemented
// in principle could support this quite easily (ldr r0, [r0, #0]) and then get closed over variables!
(void)emit;
(void)qst;
(void)local_num;
assert(0);
}

Expand Down Expand Up @@ -1465,6 +1471,9 @@ STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num)

STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
// not implemented
(void)emit;
(void)qst;
(void)local_num;
assert(0);
}

Expand Down Expand Up @@ -1634,10 +1643,16 @@ STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num)
// local is automatically deleted for exception block "as" var, and the message
// breaks tests.
//mp_emitter_warning(emit->pass, "Native codegeneration doesn't support deleting local");
(void)emit;
(void)qst;
(void)local_num;
}

STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
// TODO implement me!
(void)emit;
(void)qst;
(void)local_num;
}

STATIC void emit_native_delete_name(emit_t *emit, qstr qst) {
Expand Down Expand Up @@ -1711,7 +1726,7 @@ STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
emit_post(emit);
}

STATIC void emit_native_jump_helper(emit_t *emit, mp_uint_t label, bool pop) {
STATIC void emit_native_jump_helper(emit_t *emit, bool pop) {
vtype_kind_t vtype = peek_vtype(emit, 0);
switch (vtype) {
case VTYPE_PYOBJ:
Expand Down Expand Up @@ -1744,48 +1759,53 @@ STATIC void emit_native_jump_helper(emit_t *emit, mp_uint_t label, bool pop) {

STATIC void emit_native_pop_jump_if_true(emit_t *emit, mp_uint_t label) {
DEBUG_printf("pop_jump_if_true(label=" UINT_FMT ")\n", label);
emit_native_jump_helper(emit, label, true);
emit_native_jump_helper(emit, true);
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label);
emit_post(emit);
}

STATIC void emit_native_pop_jump_if_false(emit_t *emit, mp_uint_t label) {
DEBUG_printf("pop_jump_if_false(label=" UINT_FMT ")\n", label);
emit_native_jump_helper(emit, label, true);
emit_native_jump_helper(emit, true);
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label);
emit_post(emit);
}

STATIC void emit_native_jump_if_true_or_pop(emit_t *emit, mp_uint_t label) {
DEBUG_printf("jump_if_true_or_pop(label=" UINT_FMT ")\n", label);
emit_native_jump_helper(emit, label, false);
emit_native_jump_helper(emit, false);
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label);
adjust_stack(emit, -1);
emit_post(emit);
}

STATIC void emit_native_jump_if_false_or_pop(emit_t *emit, mp_uint_t label) {
DEBUG_printf("jump_if_false_or_pop(label=" UINT_FMT ")\n", label);
emit_native_jump_helper(emit, label, false);
emit_native_jump_helper(emit, false);
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label);
adjust_stack(emit, -1);
emit_post(emit);
}

STATIC void emit_native_break_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
(void)except_depth;
emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR); // TODO properly
}

STATIC void emit_native_continue_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
(void)except_depth;
emit_native_jump(emit, label); // TODO properly
}

STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
// not supported, or could be with runtime call
(void)emit;
(void)label;
assert(0);
}

STATIC void emit_native_with_cleanup(emit_t *emit) {
(void)emit;
assert(0);
}

Expand Down Expand Up @@ -1845,6 +1865,7 @@ STATIC void emit_native_pop_block(emit_t *emit) {
}

STATIC void emit_native_pop_except(emit_t *emit) {
(void)emit;
/*
emit_native_pre(emit);
emit_call(emit, MP_F_NLR_POP);
Expand Down Expand Up @@ -2139,6 +2160,11 @@ STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_
}

STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
(void)emit;
(void)scope;
(void)n_closed_over;
(void)n_pos_defaults;
(void)n_kw_defaults;
assert(0);
}

Expand Down Expand Up @@ -2238,10 +2264,12 @@ STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {

STATIC void emit_native_yield_value(emit_t *emit) {
// not supported (for now)
(void)emit;
assert(0);
}
STATIC void emit_native_yield_from(emit_t *emit) {
// not supported (for now)
(void)emit;
assert(0);
}

Expand Down
3 changes: 3 additions & 0 deletions py/emitpass1.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void emit_pass1_free(emit_t *emit) {
}

STATIC void emit_pass1_dummy(emit_t *emit) {
(void)emit;
}

STATIC void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
Expand All @@ -50,9 +51,11 @@ STATIC void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope
}

STATIC void emit_pass1_end_pass(emit_t *emit) {
(void)emit;
}

STATIC bool emit_pass1_last_emit_was_return_value(emit_t *emit) {
(void)emit;
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions py/modmicropython.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem
#endif

mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args) {
(void)args;
#if MICROPY_MEM_STATS
printf("mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n",
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
Expand All @@ -69,6 +70,8 @@ mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args) {
// arg given means dump gc allocation table
gc_dump_alloc_table();
}
#else
(void)n_args;
#endif
return mp_const_none;
}
Expand Down
Loading

0 comments on commit ff8dd3f

Please sign in to comment.