more strict unused variable check

This commit is contained in:
Yuichi Nishiwaki 2015-05-28 17:06:41 +09:00
parent d11da3a400
commit e30f1a11dc
7 changed files with 22 additions and 55 deletions

View File

@ -33,26 +33,20 @@ pic_dict_ref(pic_state *pic, struct pic_dict *dict, pic_sym *key)
} }
void void
pic_dict_set(pic_state *pic, struct pic_dict *dict, pic_sym *key, pic_value val) pic_dict_set(pic_state PIC_UNUSED(*pic), struct pic_dict *dict, pic_sym *key, pic_value val)
{ {
PIC_UNUSED(pic);
xh_put_ptr(&dict->hash, key, &val); xh_put_ptr(&dict->hash, key, &val);
} }
size_t size_t
pic_dict_size(pic_state *pic, struct pic_dict *dict) pic_dict_size(pic_state PIC_UNUSED(*pic), struct pic_dict *dict)
{ {
PIC_UNUSED(pic);
return dict->hash.count; return dict->hash.count;
} }
bool bool
pic_dict_has(pic_state *pic, struct pic_dict *dict, pic_sym *key) pic_dict_has(pic_state PIC_UNUSED(*pic), struct pic_dict *dict, pic_sym *key)
{ {
PIC_UNUSED(pic);
return xh_get_ptr(&dict->hash, key) != NULL; return xh_get_ptr(&dict->hash, key) != NULL;
} }

View File

@ -12,14 +12,12 @@
#include "picrin/port.h" #include "picrin/port.h"
void void
pic_panic(pic_state *pic, const char *msg) pic_panic(pic_state PIC_UNUSED(*pic), const char *msg)
{ {
PIC_UNUSED(pic);
#if DEBUG #if DEBUG
fprintf(stderr, "abort: %s\n", msg); fprintf(stderr, "abort: %s\n", msg);
#else #else
PIC_UNUSED(msg); (void)msg;
#endif #endif
PIC_ABORT(pic); PIC_ABORT(pic);

View File

@ -169,8 +169,6 @@ pic_calloc(pic_state *pic, size_t count, size_t size)
void void
pic_free(pic_state *pic, void *ptr) pic_free(pic_state *pic, void *ptr)
{ {
PIC_UNUSED(pic);
pic->allocf(ptr, 0); pic->allocf(ptr, 0);
} }

View File

@ -35,13 +35,18 @@ extern "C" {
#if __STDC_VERSION__ >= 199901L #if __STDC_VERSION__ >= 199901L
# define PIC_INLINE static inline # define PIC_INLINE static inline
#elif __GNUC__ || __clang__ #elif __GNUC__ || __clang__
# define PIC_INLINE static __attribute__((unused)) # define PIC_INLINE static __inline__
#else #else
# define PIC_INLINE static # define PIC_INLINE static
#endif #endif
#define PIC_FALLTHROUGH ((void)0) #define PIC_FALLTHROUGH ((void)0)
#define PIC_UNUSED(v) ((void)(v))
#if __GNUC__ || __clang__
# define PIC_UNUSED(v) __attribute__((unused)) v
#else
# define PIC_UNUSED(v) v
#endif
#define PIC_GENSYM2_(x,y) PIC_G##x##_##y##_ #define PIC_GENSYM2_(x,y) PIC_G##x##_##y##_
#define PIC_GENSYM1_(x,y) PIC_GENSYM2_(x,y) #define PIC_GENSYM1_(x,y) PIC_GENSYM2_(x,y)

View File

@ -91,10 +91,8 @@ case_fold(pic_state *pic, int c)
} }
static pic_value static pic_value
read_comment(pic_state *pic, struct pic_port *port, int c) read_comment(pic_state PIC_UNUSED(*pic), struct pic_port *port, int c)
{ {
PIC_UNUSED(pic);
do { do {
c = next(port); c = next(port);
} while (! (c == EOF || c == '\n')); } while (! (c == EOF || c == '\n'));
@ -103,14 +101,11 @@ read_comment(pic_state *pic, struct pic_port *port, int c)
} }
static pic_value static pic_value
read_block_comment(pic_state *pic, struct pic_port *port, int c) read_block_comment(pic_state PIC_UNUSED(*pic), struct pic_port *port, int PIC_UNUSED(c))
{ {
int x, y; int x, y;
int i = 1; int i = 1;
PIC_UNUSED(pic);
PIC_UNUSED(c);
y = next(port); y = next(port);
while (y != EOF && i > 0) { while (y != EOF && i > 0) {
@ -128,10 +123,8 @@ read_block_comment(pic_state *pic, struct pic_port *port, int c)
} }
static pic_value static pic_value
read_datum_comment(pic_state *pic, struct pic_port *port, int c) read_datum_comment(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
{ {
PIC_UNUSED(c);
read(pic, port, next(port)); read(pic, port, next(port));
return pic_undef_value(); return pic_undef_value();
@ -159,40 +152,32 @@ read_directive(pic_state *pic, struct pic_port *port, int c)
} }
static pic_value static pic_value
read_eval(pic_state *pic, struct pic_port *port, int c) read_eval(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
{ {
pic_value form; pic_value form;
PIC_UNUSED(c);
form = read(pic, port, next(port)); form = read(pic, port, next(port));
return pic_eval(pic, form, pic->lib); return pic_eval(pic, form, pic->lib);
} }
static pic_value static pic_value
read_quote(pic_state *pic, struct pic_port *port, int c) read_quote(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
{ {
PIC_UNUSED(c);
return pic_list2(pic, pic_obj_value(pic->sQUOTE), read(pic, port, next(port))); return pic_list2(pic, pic_obj_value(pic->sQUOTE), read(pic, port, next(port)));
} }
static pic_value static pic_value
read_quasiquote(pic_state *pic, struct pic_port *port, int c) read_quasiquote(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
{ {
PIC_UNUSED(c);
return pic_list2(pic, pic_obj_value(pic->sQUASIQUOTE), read(pic, port, next(port))); return pic_list2(pic, pic_obj_value(pic->sQUASIQUOTE), read(pic, port, next(port)));
} }
static pic_value static pic_value
read_unquote(pic_state *pic, struct pic_port *port, int c) read_unquote(pic_state *pic, struct pic_port *port, int PIC_UNUSED(c))
{ {
pic_sym *tag = pic->sUNQUOTE; pic_sym *tag = pic->sUNQUOTE;
PIC_UNUSED(c);
if (peek(port) == '@') { if (peek(port) == '@') {
tag = pic->sUNQUOTE_SPLICING; tag = pic->sUNQUOTE_SPLICING;
next(port); next(port);
@ -396,8 +381,6 @@ read_plus(pic_state *pic, struct pic_port *port, int c)
static pic_value static pic_value
read_true(pic_state *pic, struct pic_port *port, int c) read_true(pic_state *pic, struct pic_port *port, int c)
{ {
PIC_UNUSED(pic);
if ((c = peek(port)) == 'r') { if ((c = peek(port)) == 'r') {
if (! expect(port, "rue")) { if (! expect(port, "rue")) {
read_error(pic, "unexpected character while reading #true"); read_error(pic, "unexpected character while reading #true");
@ -412,8 +395,6 @@ read_true(pic_state *pic, struct pic_port *port, int c)
static pic_value static pic_value
read_false(pic_state *pic, struct pic_port *port, int c) read_false(pic_state *pic, struct pic_port *port, int c)
{ {
PIC_UNUSED(pic);
if ((c = peek(port)) == 'a') { if ((c = peek(port)) == 'a') {
if (! expect(port, "alse")) { if (! expect(port, "alse")) {
read_error(pic, "unexpected character while reading #false"); read_error(pic, "unexpected character while reading #false");
@ -690,12 +671,10 @@ read_label_set(pic_state *pic, struct pic_port *port, int i)
} }
static pic_value static pic_value
read_label_ref(pic_state *pic, struct pic_port *port, int i) read_label_ref(pic_state *pic, struct pic_port PIC_UNUSED(*port), int i)
{ {
xh_entry *e; xh_entry *e;
PIC_UNUSED(port);
e = xh_get_int(&pic->reader->labels, i); e = xh_get_int(&pic->reader->labels, i);
if (! e) { if (! e) {
read_error(pic, "label of given index not defined"); read_error(pic, "label of given index not defined");
@ -723,11 +702,8 @@ read_label(pic_state *pic, struct pic_port *port, int c)
} }
static pic_value static pic_value
read_unmatch(pic_state *pic, struct pic_port *port, int c) read_unmatch(pic_state *pic, struct pic_port PIC_UNUSED(*port), int PIC_UNUSED(c))
{ {
PIC_UNUSED(port);
PIC_UNUSED(c);
read_error(pic, "unmatched parenthesis"); read_error(pic, "unmatched parenthesis");
} }

View File

@ -37,9 +37,7 @@ struct pic_rope {
} while (0) } while (0)
void void
pic_rope_incref(pic_state *pic, struct pic_rope *x) { pic_rope_incref(pic_state PIC_UNUSED(*pic), struct pic_rope *x) {
PIC_UNUSED(pic);
x->refcnt++; x->refcnt++;
} }

View File

@ -163,8 +163,6 @@ write_str(pic_state *pic, struct pic_string *str, xFILE *file)
size_t i; size_t i;
const char *cstr = pic_str_cstr(pic, str); const char *cstr = pic_str_cstr(pic, str);
PIC_UNUSED(pic);
for (i = 0; i < pic_str_len(str); ++i) { for (i = 0; i < pic_str_len(str); ++i) {
if (cstr[i] == '"' || cstr[i] == '\\') { if (cstr[i] == '"' || cstr[i] == '\\') {
xfputc('\\', file); xfputc('\\', file);