From e3e44747dac9149a7468a4e6441ae74a34c63ec7 Mon Sep 17 00:00:00 2001 From: Amisi Kiarie Date: Sat, 7 Sep 2024 23:11:20 +0300 Subject: [PATCH] chore: add -pedantic --- .syntastic_c_config | 4 ++++ scripts/tmpl.mk | 2 +- src/ast/include/expr.h | 24 +++++++++++++++++------- src/ast/lex.l | 16 +++++++++------- src/include/ast.h | 16 ---------------- src/include/value.h | 2 -- src/math/math.c | 3 ++- src/value/value.c | 5 +++-- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.syntastic_c_config b/.syntastic_c_config index 889e3b3..ae44999 100644 --- a/.syntastic_c_config +++ b/.syntastic_c_config @@ -1,2 +1,6 @@ -I src/include -I build +-Werror +-Wreturn-type +-Wall +-pedantic diff --git a/scripts/tmpl.mk b/scripts/tmpl.mk index 0fd27eb..64579a1 100644 --- a/scripts/tmpl.mk +++ b/scripts/tmpl.mk @@ -2,7 +2,7 @@ # commands CC = gcc -CFLAGS = -g -I src/include -std=gnu11 -Werror -Wreturn-type -Wall +CFLAGS = -g -I src/include -std=gnu11 -Werror -Wreturn-type -Wall -pedantic VALGRIND = valgrind --fullpath-after=`pwd`/src/ LEX = lex YACC = bison -yvd diff --git a/src/ast/include/expr.h b/src/ast/include/expr.h index 74091b2..b8372fb 100644 --- a/src/ast/include/expr.h +++ b/src/ast/include/expr.h @@ -3,12 +3,6 @@ #include "util.h" -enum ast_alloc_kind { - ALLOC = 1 << 0, - DEALLOC = 1 << 1, - CLUMP = 1 << 2, -}; - struct ast_expr { enum ast_expr_kind { EXPR_IDENTIFIER = 1 << 0, @@ -77,7 +71,11 @@ struct ast_expr { } range; bool ismax; struct { - enum ast_alloc_kind kind; + enum ast_alloc_kind { + ALLOC = 1 << 0, + DEALLOC = 1 << 1, + CLUMP = 1 << 2, + } kind; struct ast_expr *arg; } alloc; } u; @@ -93,9 +91,21 @@ ast_expr_binary_create(struct ast_expr *e1, enum ast_binary_operator, enum ast_binary_operator ast_expr_binary_op(struct ast_expr *); +struct ast_expr * +ast_expr_unary_create(struct ast_expr *, enum ast_unary_operator); + +enum ast_unary_operator +ast_expr_unary_op(struct ast_expr *); + struct ast_stmt_splits ast_expr_splits(struct ast_expr *, struct state *); +enum ast_alloc_kind +ast_expr_alloc_kind(struct ast_expr *); + +struct ast_expr * +ast_expr_alloc_kind_create(struct ast_expr *arg, enum ast_alloc_kind); + struct value_arr; struct value_arr_res; diff --git a/src/ast/lex.l b/src/ast/lex.l index e4f86a3..d1d9f0c 100644 --- a/src/ast/lex.l +++ b/src/ast/lex.l @@ -165,7 +165,8 @@ comment() if ((c1 = input()) != '/' && c != EOF) { unput(c1); - return comment(); + comment(); + return; } if (c != EOF) { @@ -173,12 +174,7 @@ comment() } } -struct lexememarker marker = (struct lexememarker) { - .linenum = 0, - .column = 0, - .filename = NULL, - .flags = 0, -}; +struct lexememarker marker; struct lexememarker * lexloc() @@ -317,6 +313,12 @@ lex_begin() { table = map_create(); installclass = IC_NONE; + marker = (struct lexememarker) { + .linenum = 0, + .column = 0, + .filename = NULL, + .flags = 0, + }; } void diff --git a/src/include/ast.h b/src/include/ast.h index dd880e4..5051c83 100644 --- a/src/include/ast.h +++ b/src/include/ast.h @@ -82,17 +82,9 @@ ast_expr_member_root(struct ast_expr *); char * ast_expr_member_field(struct ast_expr *); -enum ast_unary_operator; - -struct ast_expr * -ast_expr_unary_create(struct ast_expr *, enum ast_unary_operator); - struct ast_expr * ast_expr_inverted_copy(struct ast_expr *expr, bool invert); -enum ast_unary_operator -ast_expr_unary_op(struct ast_expr *); - bool ast_expr_unary_isdereference(struct ast_expr *); @@ -204,12 +196,6 @@ ast_expr_clump_create(struct ast_expr *); struct ast_expr * ast_expr_alloc_arg(struct ast_expr *); -enum ast_alloc_kind -ast_expr_alloc_kind(struct ast_expr *); - -struct ast_expr * -ast_expr_alloc_kind_create(struct ast_expr *arg, enum ast_alloc_kind); - struct state; void @@ -499,8 +485,6 @@ ast_stmt_as_v_block(struct ast_stmt *); struct ast_expr * ast_stmt_as_expr(struct ast_stmt *); -enum execution_mode; - struct error * ast_stmt_verify(struct ast_stmt *, struct state *); diff --git a/src/include/value.h b/src/include/value.h index 822db92..5fd4054 100644 --- a/src/include/value.h +++ b/src/include/value.h @@ -134,8 +134,6 @@ bool value_references(struct value *, struct location *, struct state *, struct circuitbreaker *); -enum ast_binary_operator; - DECLARE_RESULT_TYPE(bool, bool, bool_res) struct bool_res * diff --git a/src/math/math.c b/src/math/math.c index 7317fd6..f96fc9b 100644 --- a/src/math/math.c +++ b/src/math/math.c @@ -297,7 +297,8 @@ map_sum(struct map *m1, struct map *m2) } for (int i = 0; i < m2->n; i++) { struct entry e = m2->entry[i]; - map_set(m, dynamic_str(e.key), (long) map_get(m, e.key) + e.value); + long sum = (long) map_get(m, e.key) + (long) e.value; + map_set(m, dynamic_str(e.key), (void *) sum); } map_destroy(m2); diff --git a/src/value/value.c b/src/value/value.c index 79c76f6..8bbc287 100644 --- a/src/value/value.c +++ b/src/value/value.c @@ -1256,9 +1256,10 @@ value_splitto(struct value *v, struct number *range, struct map *splits, && number_value_eq(value_lw(v, s), number_lw(range, s)) && number_value_eq(value_up(v, s), number_up(range, s)) ); - return; + break; case VALUE_RCONST: - return number_splitto(v->n, range, splits, s); + number_splitto(v->n, range, splits, s); + break; default: assert(false); } -- 2.45.2