-Werror-<warning>, -Wno-error-<warning>, manpage updated

This commit is contained in:
Wolfgang Bumiller 2012-12-20 16:49:10 +01:00
parent 78b1105c10
commit b360245b45
5 changed files with 40 additions and 10 deletions

View file

@ -399,7 +399,7 @@ bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_
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;
}
@ -408,7 +408,7 @@ bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_
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, ...)

View file

@ -56,6 +56,12 @@ Enable or disable a warning.
.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

View file

@ -898,7 +898,6 @@ typedef struct {
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 */
@ -906,6 +905,7 @@ typedef struct {
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;
@ -914,6 +914,7 @@ extern opts_cmd_t opts;
/*===================================================================*/
#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

34
main.c
View file

@ -71,8 +71,10 @@ static int usage() {
" -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"
@ -318,12 +320,18 @@ static bool options_parse(int argc, char **argv) {
}
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")) {
@ -336,7 +344,19 @@ static bool options_parse(int argc, char **argv) {
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;

3
opts.c
View file

@ -94,6 +94,9 @@ bool opts_setflag (const char *name, bool on) {
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);
}