va_end(ap);
}
+static bool irwarning(lex_ctx ctx, int warntype, const char *fmt, ...)
+{
+ va_list ap;
+ int lvl = LVL_WARNING;
+
+ if (!OPTS_WARN(warntype))
+ return false;
+
+ if (opts_werror)
+ lvl = LVL_ERROR;
+
+ va_start(ap, fmt);
+ vprintmsg(lvl, ctx.file, ctx.line, "warning", fmt, ap);
+ va_end(ap);
+
+ return opts_werror;
+}
+
/***********************************************************************
*IR Builder
*/
}
}
} while (changed);
+ if (self->blocks_count) {
+ ir_block *block = self->blocks[0];
+ for (i = 0; i < block->living_count; ++i) {
+ ir_value *v = block->living[i];
+ if (v->name[0] == '#' || v->name[0] == '%')
+ continue;
+ if (irwarning(v->context, WARN_USED_UNINITIALIZED,
+ "variable `%s` may be used uninitialized in this function", v->name))
+ {
+ return false;
+ }
+ }
+ }
return true;
}
options_set(opts_warn, WARN_FIELD_REDECLARED, true);
options_set(opts_warn, WARN_TOO_FEW_PARAMETERS, true);
options_set(opts_warn, WARN_MISSING_RETURN_VALUES, true);
+ options_set(opts_warn, WARN_USED_UNINITIALIZED, true);
if (!options_parse(argc, argv)) {
return usage();
GMQCC_DEFINE_FLAG(DEBUG)
GMQCC_DEFINE_FLAG(UNUSED_VARIABLE)
+GMQCC_DEFINE_FLAG(USED_UNINITIALIZED)
GMQCC_DEFINE_FLAG(UNKNOWN_CONTROL_SEQUENCE)
GMQCC_DEFINE_FLAG(EXTENSIONS)
GMQCC_DEFINE_FLAG(FIELD_REDECLARED)