diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-12-29 18:59:27 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-12-29 23:42:14 -0800 |
commit | 5f67b95d218e1ef3473c39bca2f6491503aeeabe (patch) | |
tree | 095d53b02f0093911e06ab06221d0529f6f7da42 /struct.c | |
parent | 0b6c09e067981c232cef09f0d82fb9b4a9864553 (diff) | |
download | txr-5f67b95d218e1ef3473c39bca2f6491503aeeabe.tar.gz txr-5f67b95d218e1ef3473c39bca2f6491503aeeabe.tar.bz2 txr-5f67b95d218e1ef3473c39bca2f6491503aeeabe.zip |
Eliminate declaration-after-statement everywhere.
The use of -ansi doesn't by itself diagnose instances of some
constructs we don't want in the project, like mixed
declarations and statements.
* configure (diag_flags): Add -Werror=declaration-after-statement.
This is C only, so filter it out for C++.
Also add -Werror=vla.
* HACKING: Update inaccurate statements about what dialect we
are using. TXR isn't pure C90: some GCC extensions are used.
We even use long long if the configure script detects it as
working, and some C99 library features.
* buf.c (replace_buf, buf_list): Fix by reordering.
* eval.c (op_dohash, op_load_time_lit): Fix by reordering.
* ffi.c (ffi_simple_release): Fix by reordering.
(align_sw_get): Fix empty macro to expand to dummy declaration
so a semicolon after it isn't interpreted as a statement.
On platforms with alignment, remove a semicolon from the macro
so that it requires one.
(ffi_i8_put, ffi_u8_put): Fix by reordering.
* gc.c (gc_init): Fix with extra braces.
* hash.c (hash_init): Fix by reordering.
* lib.c (list_collect_revappend, sub_iter, replace_str,
replace_vec, mapcar_listout, mappend, mapdo, window_map_list,
subst): Fix by reordering.
(gensym, find, rfind, pos, rpos, in, search_common): Fix by
renaming optional argument and using declaration instead of
assignment.
* linenoise/linenoise.c (edit_in_editor): Fix by reordering.
* parser.c (is_balanced_line): Fix by reordering.
* regex.c (nfa_count_one, print_rec): Fix by reordering.
* signal.c (sig_mask): Fix by reordering.
* stream.c (get_string): Fix by renaming optional argument and
using declaration instead of assignment.
* struct.c (lookup_static_slot_desc): Fix by turning mutated
variable into block local.
(umethod_args_fun): Fix by reordering.
(get_special_slot): Fix by new scope via braces.
* sysif.c (usleep_wrap): Fix by new scope via braces.
(setrlimit_wrap): Fix by new scope via braces.
* time.c (time_string_meth, time_parse_meth): Fix by reordering.
* tree.c (tr_do_delete_spec): Fix by new scope via braces.
* unwind.h (uw_block_beg): New macro which doesn't define
RESULTVAR but expects it to refers to an existing one.
(uw_block_begin): Replace do while (0) with enum trick
so that we have a declaration that requires a semicolon,
rather than a statement, allowing declarations to follow.
(uw_match_env_begin): Now opens a scope and features the
same enum trick as in uw_block_begin.
This fixes a declaration-follows-statement issue in
the v_output function in match.c.
(uw_match_env_end): Closes scope opened by uw_match_env_begin.
* unwind.c (revive_cont): Fix by introducing variable, and
using new uw_block_beg macro.
* vm.c (vm_execute_closure): Fix using combination of local
variable and reordering.
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -1167,9 +1167,9 @@ static struct stslot *lookup_static_slot_desc(struct struct_type *st, val sym) } } } else { - slot_cache = coerce(slot_cache_set_t *, - chk_calloc(SLOT_CACHE_SIZE, - sizeof (slot_cache_set_t))); + slot_cache_set_t *slot_cache = coerce(slot_cache_set_t *, + chk_calloc(SLOT_CACHE_SIZE, + sizeof *slot_cache)); slot_cache_set_t *set = &slot_cache[id % SLOT_CACHE_SIZE]; val key = cons(sym, num_fast(id)); val sl = gethash(slot_hash, key); @@ -1734,14 +1734,13 @@ static val umethod_args_fun(val dargs, struct args *args) cnum da_nargs = da->fill + c_num(length(da->list), self); cnum index = 0; val strct = args_get(args, &index); + struct struct_inst *si = struct_handle_for_slot(strct, self, sym); args_decl(args_call, max(args->fill + da_nargs, ARGS_MIN)); args_add(args_call, strct); args_cat(args_call, da); args_normalize_exact(args_call, da_nargs + 1); args_cat_zap_from(args_call, args, index); - struct struct_inst *si = struct_handle_for_slot(strct, self, sym); - if (sym && symbolp(sym)) { loc ptr = lookup_slot(strct, si, sym); if (!nullocp(ptr)) @@ -2035,10 +2034,13 @@ val static_slot_type_reg(val slot, val strct) val get_special_slot(val obj, enum special_slot spidx) { val slot = *special_sym[spidx]; - if (opt_compat && opt_compat <= 224) + + if (opt_compat && opt_compat <= 224) { return maybe_slot(obj, slot); - struct struct_inst *si = coerce(struct struct_inst *, obj->co.handle); - return get_special_static_slot(si->type, spidx, slot); + } else { + struct struct_inst *si = coerce(struct struct_inst *, obj->co.handle); + return get_special_static_slot(si->type, spidx, slot); + } } val get_special_required_slot(val obj, enum special_slot spidx) |