-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

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-21 15:49:53 +02:00
parent 5da30a46d1
commit 93856bf151
3 changed files with 24 additions and 0 deletions

22
ir.c
View file

@ -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;

1
main.c
View file

@ -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();

View file

@ -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)