From: Wolfgang (Blub) Bumiller Date: Tue, 21 Aug 2012 13:49:53 +0000 (+0200) Subject: -Wvoid-variables, QC uses 2 special void-typed variables: end_sys_globals and .end_sy... X-Git-Tag: 0.1-rc1~118 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=93856bf1518c212ee37997554ddf43f79074105e;p=xonotic%2Fgmqcc.git -Wvoid-variables, QC uses 2 special void-typed variables: end_sys_globals and .end_sys_fields. However if for some reason someone wants more, we still allow them to be code-generated, but by default warn about them by default --- diff --git a/ir.c b/ir.c index acdaa22..2261e88 100644 --- a/ir.c +++ b/ir.c @@ -2632,6 +2632,28 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global) switch (global->vtype) { + case TYPE_VOID: + if (!strcmp(global->name, "end_sys_globals")) { + /* TODO: remember this point... all the defs before this one + * should be checksummed and added to progdefs.h when we generate it. + */ + } + else if (!strcmp(global->name, "end_sys_globals")) { + /* TODO: same as above but for entity-fields rather than globsl + */ + } + else + irwarning(global->context, WARN_VOID_VARIABLES, "unrecognized variable of type void `%s`", + global->name); + /* I'd argue setting it to 0 is sufficient, but maybe some depend on knowing how far + * the system fields actually go? Though the engine knows this anyway... + * Maybe this could be an -foption + */ + ir_value_code_setaddr(global, def.offset); + /* Add the def */ + if (code_defs_add(def) < 0) + return false; + return true; case TYPE_POINTER: if (code_defs_add(def) < 0) return false; diff --git a/main.c b/main.c index d8d1c2e..2aeef3b 100644 --- a/main.c +++ b/main.c @@ -385,6 +385,7 @@ int main(int argc, char **argv) { options_set(opts_warn, WARN_MISSING_RETURN_VALUES, true); options_set(opts_warn, WARN_USED_UNINITIALIZED, true); options_set(opts_warn, WARN_LOCAL_CONSTANTS, true); + options_set(opts_warn, WARN_VOID_VARIABLE, true); if (!options_parse(argc, argv)) { return usage(); diff --git a/warns.def b/warns.def index 92a2f2b..b8609a6 100644 --- a/warns.def +++ b/warns.def @@ -12,3 +12,4 @@ GMQCC_DEFINE_FLAG(MISSING_RETURN_VALUES) GMQCC_DEFINE_FLAG(TOO_FEW_PARAMETERS) GMQCC_DEFINE_FLAG(LOCAL_SHADOWS) GMQCC_DEFINE_FLAG(LOCAL_CONSTANTS) +GMQCC_DEFINE_FLAG(VOID_VARIABLES)