]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
-Werror-<warning>, -Wno-error-<warning>, manpage updated
authorWolfgang Bumiller <blub@speed.at>
Thu, 20 Dec 2012 15:49:10 +0000 (16:49 +0100)
committerWolfgang Bumiller <blub@speed.at>
Thu, 20 Dec 2012 15:49:10 +0000 (16:49 +0100)
conout.c
doc/gmqcc.1
gmqcc.h
main.c
opts.c

index 3fca6ef76fbdd8a576e85beaec822e700581e704..2c9962d4a50329cc588e4f14934150c6ed35eca6 100644 (file)
--- 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, ...)
index 8b86efee68cef42dc38b55dbd99a617817730f40..161811bf5c7bbadf9e7fcf2d55a0056c6cc98c0d 100644 (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
diff --git a/gmqcc.h b/gmqcc.h
index d39eda3acddbbee9cc1db8a6534f851fd8443b13..fdcb56ba8a5efa4f1a5dfe0c313600c5b8e1954c 100644 (file)
--- 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 6a0fe1667a60a740fd7db2cd23323edaaa0c787b..36fe844daec66b2a3683f5484680df8c6276cb3f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -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;
diff --git a/opts.c b/opts.c
index 2a7dc8d3dde16507aa9b1948d28dddc6489732e6..b8abedd7188e9f3661aa60938b4ee7159f6080b1 100644 (file)
--- 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);
 }