- fixed source position of binary expressions
[cparser] / warning.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "warning.h"
4
5 void set_warning_opt(const char *const opt)
6 {
7         const char* s = opt;
8
9         bool state = true;
10         /* no- modifier */
11         if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
12                 s += 3;
13                 state = false;
14         }
15
16         if (0) {}
17 #define OPTX(x)   else if (strcmp(s, x) == 0)
18 #define SET(y)    warning.y = state;
19 #define OPT(x, y) OPTX(x) SET(y)
20         OPT("char-subscripts",               char_subscripts)
21         OPT("empty-statement",               empty_statement)
22         OPT("error",                         s_are_errors)
23         OPT("fatal-errors",                  fatal_errors)
24         OPT("float-equal",                   float_equal)
25         OPT("format",                        check_format)
26         OPTX("implicit") {
27                 SET(implicit_function_declaration)
28                 SET(implicit_int)
29         }
30         OPT("implicit-function-declaration", implicit_function_declaration)
31         OPT("implicit-int",                  implicit_int)
32         OPT("main",                          main)
33         OPT("missing-declarations",          missing_declarations)
34         OPT("missing-prototypes",            missing_prototypes)
35         OPT("redundant-decls",               redundant_decls)
36         OPT("strict-prototypes",             strict_prototypes)
37         OPT("switch-default",                switch_default)
38         OPT("unknown-pragmas",               unknown_pragmas)
39         OPT("unused-label",                  unused_label)
40 #if 0
41         OPTX("unused") {
42                 SET(unused_function)
43                 SET(unused_label)
44                 SET(unused_parameter)
45                 SET(unused_variable)
46                 SET(unused_value)
47         }
48 #endif
49         OPT("unused-value",                  unused_value)
50 #undef OPT
51 #undef SET
52 #undef OPT_X
53         else {
54                 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);
55         }
56 }
57
58 warning_t warning = {
59         .char_subscripts               = true,
60         .check_format                  = true,
61         .empty_statement               = false,
62         .fatal_errors                  = false,
63         .float_equal                   = false,
64         .implicit_function_declaration = true,
65         .implicit_int                  = true,
66         .main                          = true,
67         .missing_declarations          = true,
68         .missing_prototypes            = true,
69         .redundant_decls               = true,
70         .s_are_errors                  = false,
71         .strict_prototypes             = true,
72         .switch_default                = false,
73         .unknown_pragmas               = true,
74         .unused_label                  = false,
75         .unused_value                  = true
76 };