warn_name[1] = 'W';
(void)util_strtononcmd(opts_warn_list[warntype].name, warn_name+2, sizeof(warn_name)-2);
- if (opts.werror) {
+ if (OPTS_WERROR(warntype)) {
++compile_errors;
lvl = LVL_ERROR;
}
con_vprintmsg_c(lvl, ctx.file, ctx.line, (opts.werror ? "error" : "warning"), fmt, ap, warn_name);
- return opts.werror;
+ return OPTS_WERROR(warntype);
}
bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...)
.B -Wall
Enable all warnings. Overrides preceding -W parameters.
.TP
+.BR -Werror ", " -Wno-error
+Controls whether or not all warnings should be treated as errors.
+.TP
+.BI -Werror- warning "\fR, " "" -Wno-error- warning
+Controls whether a specific warning should be an error.
+.TP
.B -Whelp
List all possible warn flags.
.TP
bool memchk; /* -memchk */
bool dumpfin; /* -dumpfin */
bool dump; /* -dump */
- bool werror; /* -Werror */
bool forcecrc; /* --force-crc= */
uint16_t forced_crc; /* --force-crc= */
bool pp_only; /* -E */
uint32_t flags [1 + (COUNT_FLAGS / 32)];
uint32_t warn [1 + (COUNT_WARNINGS / 32)];
+ uint32_t werror [1 + (COUNT_WARNINGS / 32)];
uint32_t optimization[1 + (COUNT_OPTIMIZATIONS / 32)];
} opts_cmd_t;
/*===================================================================*/
#define OPTS_FLAG(i) (!! (opts.flags [(i)/32] & (1<< ((i)%32))))
#define OPTS_WARN(i) (!! (opts.warn [(i)/32] & (1<< ((i)%32))))
+#define OPTS_WERROR(i) (!! (opts.werror [(i)/32] & (1<< ((i)%32))))
#define OPTS_OPTIMIZATION(i) (!! (opts.optimization[(i)/32] & (1<< ((i)%32))))
#endif
" -fhelp list possible flags\n");
con_out(" -W<warning> enable a warning\n"
" -Wno-<warning> disable a warning\n"
- " -Wall enable all warnings\n"
- " -Werror treat warnings as errors\n");
+ " -Wall enable all warnings\n");
+ con_out(" -Werror treat warnings as errors\n"
+ " -Werror-<warning> treat a warning as error\n"
+ " -Wno-error-<warning> opposite of the above\n");
con_out(" -Whelp list possible warnings\n");
con_out(" -O<number> optimization level\n"
" -O<name> enable specific optimization\n"
}
exit(0);
}
- else if (!strcmp(argv[0]+2, "NO_ERROR")) {
- opts.werror = false;
+ else if (!strcmp(argv[0]+2, "NO_ERROR") ||
+ !strcmp(argv[0]+2, "NO_ERROR_ALL"))
+ {
+ for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
+ opts.werror[itr] = 0;
break;
}
- else if (!strcmp(argv[0]+2, "ERROR")) {
- opts.werror = true;
+ else if (!strcmp(argv[0]+2, "ERROR") ||
+ !strcmp(argv[0]+2, "ERROR_ALL"))
+ {
+ for (itr = 0; itr < sizeof(opts.werror)/sizeof(opts.werror[0]); ++itr)
+ opts.werror[itr] = 0xFFFFFFFFL;
break;
}
else if (!strcmp(argv[0]+2, "NONE")) {
opts.warn[itr] = 0xFFFFFFFFL;
break;
}
- if (!strncmp(argv[0]+2, "NO_", 3)) {
+ else if (!strncmp(argv[0]+2, "ERROR_", 6)) {
+ if (!opts_setwarn(argv[0]+8, true)) {
+ con_out("unknown warning: %s\n", argv[0]+2);
+ return false;
+ }
+ }
+ else if (!strncmp(argv[0]+2, "NO_ERROR_", 9)) {
+ if (!opts_setwarn(argv[0]+11, false)) {
+ con_out("unknown warning: %s\n", argv[0]+2);
+ return false;
+ }
+ }
+ else if (!strncmp(argv[0]+2, "NO_", 3)) {
if (!opts_setwarn(argv[0]+5, false)) {
con_out("unknown warning: %s\n", argv[0]+2);
return false;
bool opts_setwarn (const char *name, bool on) {
return opts_setflag_all(name, on, opts.warn, opts_warn_list, COUNT_WARNINGS);
}
+bool opts_setwerror(const char *name, bool on) {
+ return opts_setflag_all(name, on, opts.werror, opts_warn_list, COUNT_WARNINGS);
+}
bool opts_setoptim(const char *name, bool on) {
return opts_setflag_all(name, on, opts.optimization, opts_opt_list, COUNT_OPTIMIZATIONS);
}