Quick Search:

Mode

Context

Displaying 6 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.109
 
1.110
 
MAIN:plunky:20140606131903
 
common.c
_>163163         if (warniserr)
 164164                 incerr();
 165165 }
 166166 
 167167 #ifndef MKEXT
 168168 
<>169 -bittype warnary[(NUMW/NUMBITS)+1], werrary[(NUMW/NUMBITS)+1];
 170 -
 171 -static char *warntxt[] = {
 172 -        "conversion from '%s' to '%s' may alter its value", /* Wtruncate */
 173 -        "function declaration isn't a prototype", /* Wstrict_prototypes */
 174 -        "no previous prototype for `%s'", /* Wmissing_prototypes */
 175 -        "return type defaults to `int'", /* Wimplicit_int */
 176 -                 /* Wimplicit_function_declaration */
 177 -        "implicit declaration of function '%s'",
 178 -        "declaration of '%s' shadows a %s declaration", /* Wshadow */
 179 -        "illegal pointer combination", /* Wpointer_sign */
 180 -        "comparison between signed and unsigned", /* Wsign_compare */
 181 -        "ignoring #pragma %s %s", /* Wunknown_pragmas */
 182 -        "statement not reached", /* Wunreachable_code */
  169+struct Warning {
  170+        char *flag;
  171+        int warn;
  172+        int err;
  173+        char *fmt;
183174 };
 184175 
<>185 -char *flagstr[] = {
 186 -        "truncate", "strict-prototypes", "missing-prototypes",
 187 -        "implicit-int", "implicit-function-declaration", "shadow",
 188 -        "pointer-sign", "sign-compare", "unknown-pragmas",
 189 -        "unreachable-code",
  176+/*
  177+ * conditional warnings
  178+ */
  179+struct Warning Warnings[] = {
  180+        {
  181+                "truncate", 0, 0,
  182+                "conversion from '%s' to '%s' may alter its value"
  183+        }, {
  184+                "strict-prototypes", 0, 0,
  185+                "function declaration isn't a prototype"
  186+        }, {
  187+                "missing-prototypes", 0, 0,
  188+                "no previous prototype for `%s'"
  189+        }, {
  190+                "implicit-int", 0, 0,
  191+                "return type defaults to `int'",
  192+        }, {
  193+                "implicit-function-declaration", 0, 0,
  194+                "implicit declaration of function '%s'"
  195+        }, {
  196+                "shadow", 0, 0,
  197+                "declaration of '%s' shadows a %s declaration"
  198+        }, {
  199+                "pointer-sign", 0, 0,
  200+                "illegal pointer combination"
  201+        }, {
  202+                "sign-compare", 0, 0,
  203+                "comparison between signed and unsigned"
  204+        }, {
  205+                "unknown-pragmas", 0, 0,
  206+                "ignoring #pragma %s %s"
  207+        }, {
  208+                "unreachable-code", 0, 0,
  209+                "statement not reached"
  210+        }, {
  211+                "deprecated-declarations", 1, 0,
  212+                "`%s' is deprecated"
  213+        }, {    NULL    }
190214 };
 191215 
 192216 /*
<>193 - * "emulate" the gcc warning flags.
  217+ * set the warn/err status of a conditional warning
194218  */
<> 219+int
  220+Wset(char *str, int warn, int err)
  221+{
  222+        struct Warning *w = Warnings;
  223+
  224+        for (w = Warnings; w->flag; w++) {
  225+                if (strcmp(w->flag, str) == 0) {
  226+                        w->warn = warn;
  227+                        w->err = err;
  228+                        return 0;
  229+                }
  230+        }
  231+        return 1;
  232+}
  233+
  234+/*
  235+ * handle a conditional warning flag.
  236+ */
195237 void
 196238 Wflags(char *str)
 197239 {
<>198 -        int i, isset, iserr;
  240+        struct Warning *w;
  241+        int isset, iserr;
199242 
 200243         /* handle -Werror specially */
 201244         if (strcmp("error", str) == 0) {
<>202 -                for (i = 0; i < NUMW; i++)
 203 -                        BITSET(werrary, i);
  245+                for (w = Warnings; w->flag; w++)
  246+                        w->err = 1;
204247 
 205248                 warniserr = 1;
 206249                 return;
 207250         }
 208251 
 209252         isset = 1;
     
 !
215258         iserr = 0;
 216259         if (strncmp("error=", str, 6) == 0) {
 217260                 str += 6;
 218261                 iserr = 1;
 219262         }
 220263 
<>221 -        for (i = 0; i < NUMW; i++) {
 222 -                if (strcmp(flagstr[i], str) != 0)
  264+        for (w = Warnings; w->flag; w++) {
  265+                if (strcmp(w->flag, str) != 0)
223266                         continue;
 224267 
 225268                 if (isset) {
 226269                         if (iserr)
<>227 -                                BITSET(werrary, i);
 228 -                        BITSET(warnary, i);
  270+                                w->err = 1;
  271+                        w->warn = 1;
229272                 } else if (iserr) {
<>230 -                        BITCLEAR(werrary, i);
  273+                        w->err = 0;
231274                 } else {
<>232 -                        BITCLEAR(warnary, i);
  275+                        w->warn = 0;
233276                 }
 234277 
 235278                 return;
 236279         }
 237280 
 238281         fprintf(stderr, "unrecognised warning option '%s'\n", str);
 239282 }
 240283 
 241284 /*
<>242 - * Deal with gcc warnings.
  285+ * emit a conditional warning
243286  */
 244287 void
 245288 warner(int type, ...)
 246289 {
 247290         va_list ap;
<>248 -        char *w;
  291+        char *t;
249292         extern int issyshdr;
 250293 
 251294         if (issyshdr && type == Wtruncate)
 252295                 return; /* Too many false positives */
 253296 
<>254 -        if (TESTBIT(warnary, type) == 0)
  297+        if (Warnings[type].warn == 0)
255298                 return; /* no warning */
<>256 -        if (TESTBIT(werrary, type)) {
 257 -                w = "error";
  299+        if (Warnings[type].err) {
  300+                t = "error";
258301                 incerr();
 259302         } else
<>260 -                w = "warning";
  303+                t = "warning";
261304 
 262305         va_start(ap, type);
<>263 -        fprintf(stderr, "%s:%d: %s: ", ftitle, lineno, w);
 264 -        vfprintf(stderr, warntxt[type], ap);
  306+        fprintf(stderr, "%s:%d: %s: ", ftitle, lineno, t);
  307+        vfprintf(stderr, Warnings[type].fmt, ap);
<_265308         fprintf(stderr, "\n");
 266309         va_end(ap);
 267310 }
 268311 #endif /* MKEXT */
 269312 
 270313 #ifndef MKEXT
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-10-31 05:06 +0100