2 * This file is part of cparser.
3 * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 .char_subscripts = true,
27 .empty_statement = false,
28 .fatal_errors = false,
31 .implicit_function_declaration = true,
34 .missing_declarations = false,
35 .missing_prototypes = false,
38 .redundant_decls = true,
40 .s_are_errors = false,
42 .sign_compare = false,
43 .strict_prototypes = true,
44 .switch_default = false,
45 .unknown_pragmas = true,
46 .unreachable_code = false,
47 .unused_function = false,
48 .unused_label = false,
49 .unused_parameter = false,
51 .unused_variable = false
54 void set_warning_opt(const char *const opt)
61 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
67 #define OPTX(x) else if (strcmp(s, x) == 0)
68 #define SET(y) (void)(warning.y = state)
69 #define OPT(x, y) OPTX(x) SET(y)
71 /* Note: this switched on a lot of more warnings than gcc's -Wall */
76 SET(implicit_function_declaration);
84 SET(strict_prototypes);
86 SET(unreachable_code);
89 SET(unused_parameter);
93 OPT("attribute", attribute);
94 OPT("char-subscripts", char_subscripts);
95 OPT("empty-statement", empty_statement);
96 OPT("error", s_are_errors);
99 // TODO SET(function_end_without_return);
100 SET(empty_statement);
101 // TODO SET(incomplete_aggregate_init);
102 // TODO SET(pointless_comparison);
103 SET(unused_parameter);
106 OPT("fatal-errors", fatal_errors);
107 OPT("float-equal", float_equal);
113 SET(implicit_function_declaration);
116 OPT("implicit-function-declaration", implicit_function_declaration);
117 OPT("implicit-int", implicit_int);
119 OPT("missing-declarations", missing_declarations);
120 OPT("missing-prototypes", missing_prototypes);
121 OPT("multichar", multichar);
122 OPT("nonnull", nonnull);
123 OPT("redundant-decls", redundant_decls);
124 OPT("return-type", return_type);
125 OPT("shadow", shadow);
126 OPT("sign-compare", sign_compare);
127 OPT("strict-prototypes", strict_prototypes);
128 OPT("switch-default", switch_default);
129 OPT("unknown-pragmas", unknown_pragmas);
130 OPT("unreachable-code", unreachable_code);
132 SET(unused_function);
134 SET(unused_parameter);
136 SET(unused_variable);
138 OPT("unused-function", unused_function);
139 OPT("unused-label", unused_label);
140 OPT("unused-parameter", unused_parameter);
141 OPT("unused-value", unused_value);
142 OPT("unused-variable", unused_variable);
147 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);