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
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);
}
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;
}
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;
}

View File

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

View File

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

View File

@ -35,13 +35,18 @@ extern "C" {
#if __STDC_VERSION__ >= 199901L
# define PIC_INLINE static inline
#elif __GNUC__ || __clang__
# define PIC_INLINE static __attribute__((unused))
# define PIC_INLINE static __inline__
#else
# define PIC_INLINE static
#endif
#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_GENSYM1_(x,y) PIC_GENSYM2_(x,y)

View File

@ -91,10 +91,8 @@ case_fold(pic_state *pic, int c)
}
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 {
c = next(port);
} while (! (c == EOF || c == '\n'));
@ -103,14 +101,11 @@ read_comment(pic_state *pic, struct pic_port *port, int c)
}
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 i = 1;
PIC_UNUSED(pic);
PIC_UNUSED(c);
y = next(port);
while (y != EOF && i > 0) {
@ -128,10 +123,8 @@ read_block_comment(pic_state *pic, struct pic_port *port, int c)
}
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));
return pic_undef_value();
@ -159,40 +152,32 @@ read_directive(pic_state *pic, struct pic_port *port, int c)
}
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_UNUSED(c);
form = read(pic, port, next(port));
return pic_eval(pic, form, pic->lib);
}
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)));
}
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)));
}
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_UNUSED(c);
if (peek(port) == '@') {
tag = pic->sUNQUOTE_SPLICING;
next(port);
@ -396,8 +381,6 @@ read_plus(pic_state *pic, struct pic_port *port, int c)
static pic_value
read_true(pic_state *pic, struct pic_port *port, int c)
{
PIC_UNUSED(pic);
if ((c = peek(port)) == 'r') {
if (! expect(port, "rue")) {
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
read_false(pic_state *pic, struct pic_port *port, int c)
{
PIC_UNUSED(pic);
if ((c = peek(port)) == 'a') {
if (! expect(port, "alse")) {
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
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;
PIC_UNUSED(port);
e = xh_get_int(&pic->reader->labels, i);
if (! e) {
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
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");
}

View File

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

View File

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