From: Wolfgang Bumiller Date: Thu, 20 Dec 2012 15:49:10 +0000 (+0100) Subject: -Werror-, -Wno-error-, manpage updated X-Git-Tag: 0.1.9~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b360245b45856d709213a255af225c840cb08882;p=xonotic%2Fgmqcc.git -Werror-, -Wno-error-, manpage updated --- diff --git a/conout.c b/conout.c index 3fca6ef..2c9962d 100644 --- a/conout.c +++ b/conout.c @@ -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, ...) diff --git a/doc/gmqcc.1 b/doc/gmqcc.1 index 8b86efe..161811b 100644 --- a/doc/gmqcc.1 +++ b/doc/gmqcc.1 @@ -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 diff --git a/gmqcc.h b/gmqcc.h index d39eda3..fdcb56b 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -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 diff --git a/main.c b/main.c index 6a0fe16..36fe844 100644 --- a/main.c +++ b/main.c @@ -71,8 +71,10 @@ static int usage() { " -fhelp list possible flags\n"); con_out(" -W enable a warning\n" " -Wno- 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- treat a warning as error\n" + " -Wno-error- opposite of the above\n"); con_out(" -Whelp list possible warnings\n"); con_out(" -O optimization level\n" " -O 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; diff --git a/opts.c b/opts.c index 2a7dc8d..b8abedd 100644 --- a/opts.c +++ b/opts.c @@ -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); }