Remove some shadowed variables
This commit is contained in:
parent
8847eaa660
commit
d5d3f564bb
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ CCONFIG=-std=c11 -Werror -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -fPIC -I.
|
||||
LTO=-flto=auto -fno-fat-lto-objects -Wl,-flto
|
||||
LDFLAGS=-Wl,-rpath '-Wl,$$ORIGIN'
|
||||
# MAKEFLAGS := --jobs=$(shell nproc) --output-sync=target
|
||||
CWARN=-Wall -Wextra -Wno-format
|
||||
CWARN=-Wall -Wextra -Wno-format -Wshadow
|
||||
# -Wpedantic -Wsign-conversion -Wtype-limits -Wunused-result -Wnull-dereference \
|
||||
# -Waggregate-return -Walloc-zero -Walloca -Warith-conversion -Wcast-align -Wcast-align=strict \
|
||||
# -Wdangling-else -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches \
|
||||
|
@ -297,7 +297,7 @@ public int fprint_span(FILE *out, file_t *file, const char *start, const char *e
|
||||
for (int num = 0; num < digits; num++)
|
||||
printed += fputc(' ', out);
|
||||
printed += fputs(": ", out);
|
||||
int column = 0;
|
||||
int col = 0;
|
||||
for (const char *sp = line; *sp && *sp != '\n'; ++sp) {
|
||||
char print_char;
|
||||
if (sp < start)
|
||||
@ -308,7 +308,7 @@ public int fprint_span(FILE *out, file_t *file, const char *start, const char *e
|
||||
print_char = '-';
|
||||
else
|
||||
print_char = ' ';
|
||||
printed += fputc_column(out, *sp, print_char, &column);
|
||||
printed += fputc_column(out, *sp, print_char, &col);
|
||||
}
|
||||
printed += fputs("\n", out);
|
||||
}
|
||||
|
@ -248,9 +248,9 @@ public array_t Text__split(CORD str, CORD split)
|
||||
|
||||
i += non_split;
|
||||
|
||||
size_t split = u8_strspn(ustr + i, usplit);
|
||||
if (split == 0) break;
|
||||
i += split;
|
||||
size_t split_span = u8_strspn(ustr + i, usplit);
|
||||
if (split_span == 0) break;
|
||||
i += split_span;
|
||||
}
|
||||
return strings;
|
||||
}
|
||||
|
22
compile.c
22
compile.c
@ -699,7 +699,7 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
if (!array->items)
|
||||
return "(array_t){.length=0}";
|
||||
|
||||
type_t *array_t = get_type(env, ast);
|
||||
type_t *array_type = get_type(env, ast);
|
||||
|
||||
int64_t n = 0;
|
||||
for (ast_list_t *item = array->items; item; item = item->next) {
|
||||
@ -708,17 +708,19 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
goto array_comprehension;
|
||||
}
|
||||
|
||||
type_t *item_type = Match(array_t, ArrayType)->item_type;
|
||||
{
|
||||
type_t *item_type = Match(array_type, ArrayType)->item_type;
|
||||
CORD code = CORD_all("$TypedArrayN(", compile_type(item_type), CORD_asprintf(", %ld", n));
|
||||
for (ast_list_t *item = array->items; item; item = item->next)
|
||||
code = CORD_all(code, ", ", compile(env, item->ast));
|
||||
return CORD_cat(code, ")");
|
||||
}
|
||||
|
||||
array_comprehension:
|
||||
{
|
||||
CORD code = "({ array_t $arr = {};";
|
||||
env_t *scope = fresh_scope(env);
|
||||
set_binding(scope, "$arr", new(binding_t, .type=array_t, .code="$arr"));
|
||||
set_binding(scope, "$arr", new(binding_t, .type=array_type, .code="$arr"));
|
||||
for (ast_list_t *item = array->items; item; item = item->next) {
|
||||
if (item->ast->tag == For) {
|
||||
auto for_ = Match(item->ast, For);
|
||||
@ -749,9 +751,9 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
return CORD_cat(code, "}");
|
||||
}
|
||||
|
||||
type_t *table_t = get_type(env, ast);
|
||||
type_t *key_t = Match(table_t, TableType)->key_type;
|
||||
type_t *value_t = Match(table_t, TableType)->value_type;
|
||||
type_t *table_type = get_type(env, ast);
|
||||
type_t *key_t = Match(table_type, TableType)->key_type;
|
||||
type_t *value_t = Match(table_type, TableType)->value_type;
|
||||
CORD code = CORD_all("$Table(",
|
||||
compile_type(key_t), ", ",
|
||||
compile_type(value_t), ", ",
|
||||
@ -992,10 +994,10 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
} else code_err(ast, "There is no '%s' method for tables", call->name);
|
||||
}
|
||||
default: {
|
||||
auto call = Match(ast, MethodCall);
|
||||
type_t *fn_t = get_method_type(env, call->self, call->name);
|
||||
arg_ast_t *args = new(arg_ast_t, .value=call->self, .next=call->args);
|
||||
binding_t *b = get_namespace_binding(env, call->self, call->name);
|
||||
auto methodcall = Match(ast, MethodCall);
|
||||
type_t *fn_t = get_method_type(env, methodcall->self, methodcall->name);
|
||||
arg_ast_t *args = new(arg_ast_t, .value=methodcall->self, .next=methodcall->args);
|
||||
binding_t *b = get_namespace_binding(env, methodcall->self, methodcall->name);
|
||||
if (!b) code_err(ast, "No such method");
|
||||
return CORD_all(b->code, "(", compile_arguments(env, ast, Match(fn_t, FunctionType)->args, args), ")");
|
||||
}
|
||||
|
@ -8,11 +8,6 @@
|
||||
#include "typecheck.h"
|
||||
#include "builtins/util.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
binding_t binding;
|
||||
} ns_entry_t;
|
||||
|
||||
env_t *new_compilation_unit(void)
|
||||
{
|
||||
env_t *env = new(env_t);
|
||||
|
6
parse.c
6
parse.c
@ -233,14 +233,14 @@ static void expect_str(
|
||||
// Helper for matching closing parens with good error messages
|
||||
//
|
||||
static void expect_closing(
|
||||
parse_ctx_t *ctx, const char **pos, const char *closing, const char *fmt, ...) {
|
||||
parse_ctx_t *ctx, const char **pos, const char *close_str, const char *fmt, ...) {
|
||||
const char *start = *pos;
|
||||
spaces(pos);
|
||||
if (match(pos, closing))
|
||||
if (match(pos, close_str))
|
||||
return;
|
||||
|
||||
const char *eol = strchr(*pos, '\n');
|
||||
const char *next = strstr(*pos, closing);
|
||||
const char *next = strstr(*pos, close_str);
|
||||
|
||||
const char *end = eol < next ? eol : next;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user