From 5e605aee36d932779d6c99432340fd6520411a40 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 20 Nov 2024 17:00:54 +0900 Subject: [PATCH] [qfcc] Clean up some overzealous const correctness I'm not sure why I made those functions take const type_t *, but they didn't need it. There's still a relevant fixime in find_handle, but I haven't decided how to fix that one just yet. --- tools/qfcc/include/struct.h | 6 +++--- tools/qfcc/source/struct.c | 11 +++++------ tools/qfcc/source/stub.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/qfcc/include/struct.h b/tools/qfcc/include/struct.h index 01a00ccf5..bfc642d83 100644 --- a/tools/qfcc/include/struct.h +++ b/tools/qfcc/include/struct.h @@ -48,9 +48,9 @@ struct symbol_s *find_handle (struct symbol_s *tag, const type_t *type); struct symtab_s *start_struct (int *su, struct symbol_s *tag, struct symtab_s *parent); struct symbol_s *find_struct (int su, struct symbol_s *tag, - const type_t *type); + type_t *type); struct symbol_s *build_struct (int su, struct symbol_s *tag, - struct symtab_s *symtab, const type_t *type, + struct symtab_s *symtab, type_t *type, int base); struct symbol_s *find_enum (struct symbol_s *tag); struct symtab_s *start_enum (struct symbol_s *enm); @@ -61,7 +61,7 @@ bool enum_as_bool (const type_t *enm, struct expr_s **zero, struct expr_s **one); struct symbol_s *make_structure (const char *name, int su, struct_def_t *defs, - const type_t *type); + type_t *type); struct defspace_s; struct def_s * emit_structure (const char *name, int su, struct_def_t *defs, const type_t *type, void *data, diff --git a/tools/qfcc/source/struct.c b/tools/qfcc/source/struct.c index bf258480a..74b873970 100644 --- a/tools/qfcc/source/struct.c +++ b/tools/qfcc/source/struct.c @@ -65,7 +65,7 @@ #include "tools/qfcc/include/value.h" static symbol_t * -find_tag (ty_meta_e meta, symbol_t *tag, const type_t *type) +find_tag (ty_meta_e meta, symbol_t *tag, type_t *type) { const char *tag_name; symbol_t *sym; @@ -87,7 +87,7 @@ find_tag (ty_meta_e meta, symbol_t *tag, const type_t *type) return sym; } sym = new_symbol (tag_name); - type_t *t = (type_t *) type;//FIXME + type_t *t = type; if (!t) t = new_type (); if (!t->name) @@ -146,7 +146,7 @@ find_handle (symbol_t *tag, const type_t *type) } symbol_t * -find_struct (int su, symbol_t *tag, const type_t *type) +find_struct (int su, symbol_t *tag, type_t *type) { ty_meta_e meta = ty_struct; @@ -157,7 +157,7 @@ find_struct (int su, symbol_t *tag, const type_t *type) } symbol_t * -build_struct (int su, symbol_t *tag, symtab_t *symtab, const type_t *type, +build_struct (int su, symbol_t *tag, symtab_t *symtab, type_t *type, int base) { symbol_t *sym = find_struct (su, tag, type); @@ -344,8 +344,7 @@ enum_as_bool (const type_t *enm, expr_t **zero, expr_t **one) } symbol_t * -make_structure (const char *name, int su, struct_def_t *defs, - const type_t *type) +make_structure (const char *name, int su, struct_def_t *defs, type_t *type) { symtab_t *strct; symbol_t *field; diff --git a/tools/qfcc/source/stub.c b/tools/qfcc/source/stub.c index 24abdde11..1504ce41e 100644 --- a/tools/qfcc/source/stub.c +++ b/tools/qfcc/source/stub.c @@ -55,7 +55,7 @@ void def_to_ddef (def_t *def, ddef_t *ddef, int aux) {} __attribute__((noreturn)) void _internal_error (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {abort();} void _warning (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {} __attribute__((const)) const expr_t *_error (const expr_t *e, const char *file, int line, const char *func, const char *fmt, ...) {return 0;} -__attribute__((const)) symbol_t *make_structure (const char *name, int su, struct_def_t *defs, const type_t *type) {return 0;} +__attribute__((const)) symbol_t *make_structure (const char *name, int su, struct_def_t *defs, type_t *type) {return 0;} __attribute__((const)) symbol_t *symtab_addsymbol (symtab_t *symtab, symbol_t *symbol) {return 0;} __attribute__((const)) symbol_t *new_symbol_type (const char *name, const type_t *type) {return 0;} __attribute__((const)) def_t *qfo_encode_type (const type_t *type, defspace_t *space) {return 0;}