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
28 .aggregate_return = false,
31 .char_subscripts = true,
34 .declaration_after_statement = false,
35 .deprecated_declarations = true,
37 .empty_statement = false,
38 .error_implicit_function_declaration = false,
39 .fatal_errors = false,
42 .implicit_function_declaration = true,
47 .missing_declarations = false,
48 .missing_noreturn = false,
49 .missing_prototypes = false,
51 .nested_externs = false,
53 .old_style_definition = false,
57 .pointer_arith = true,
58 .redundant_decls = true,
60 .s_are_errors = false,
62 .sign_compare = false,
63 .strict_prototypes = true,
64 .switch_default = false,
67 .unknown_pragmas = true,
68 .unreachable_code = false,
69 .unused_function = false,
70 .unused_label = false,
71 .unused_parameter = false,
73 .unused_variable = false,
74 .write_strings = false
77 void set_warning_opt(const char *const opt)
84 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
90 #define OPTX(x) else if (strcmp(s, x) == 0)
91 #define SET(y) (void)(warning.y = state)
92 #define OPT(x, y) OPTX(x) SET(y)
94 /* Note: this switched on a lot more warnings than gcc's -Wall */
101 SET(empty_statement);
103 SET(implicit_function_declaration);
110 SET(redundant_decls);
114 SET(strict_prototypes);
116 SET(unknown_pragmas);
117 SET(unreachable_code);
118 SET(unused_function);
120 SET(unused_parameter);
122 SET(unused_variable);
124 OPT("address", address);
125 OPT("aggregate-return", aggregate_return);
126 OPT("attribute", attribute);
127 OPT("cast-qual", cast_qual);
128 OPT("char-subscripts", char_subscripts);
129 OPT("comment", comment);
130 OPT("conversion", conversion);
131 OPT("declaration-after-statement", declaration_after_statement);
132 OPT("deprecated-declarations", deprecated_declarations);
133 OPT("div-by-zero", div_by_zero);
134 OPT("empty-statement", empty_statement);
135 OPT("error", s_are_errors);
136 OPT("error-implicit-function-declaration", error_implicit_function_declaration);
139 // TODO SET(function_end_without_return);
140 SET(empty_statement);
141 // TODO SET(incomplete_aggregate_init);
142 // TODO SET(missing_field_initializers);
143 // TODO SET(pointless_comparison);
144 SET(unused_parameter);
147 OPT("fatal-errors", fatal_errors);
148 OPT("float-equal", float_equal);
154 SET(implicit_function_declaration);
157 OPT("implicit-function-declaration", implicit_function_declaration);
158 OPT("implicit-int", implicit_int);
159 OPT("init-self", init_self);
160 OPT("long-long", long_long);
162 OPT("missing-declarations", missing_declarations);
163 OPT("missing-noreturn", missing_noreturn);
164 OPT("missing-prototypes", missing_prototypes);
165 OPT("multichar", multichar);
166 OPT("nested-externs", nested_externs);
167 OPT("nonnull", nonnull);
168 OPT("old-style-definition", old_style_definition);
169 OPT("packed", packed);
170 OPT("padded", padded);
171 OPT("parentheses", parentheses);
172 OPT("pointer-arith", pointer_arith);
173 OPT("redundant-decls", redundant_decls);
174 OPT("return-type", return_type);
175 OPT("shadow", shadow);
176 OPT("sign-compare", sign_compare);
177 OPT("strict-prototypes", strict_prototypes);
178 OPT("switch-default", switch_default);
179 OPT("switch-enum", switch_enum);
180 OPT("traditional", traditional);
181 OPT("unknown-pragmas", unknown_pragmas);
182 OPT("unreachable-code", unreachable_code);
184 SET(unused_function);
186 SET(unused_parameter);
188 SET(unused_variable);
190 OPT("unused-function", unused_function);
191 OPT("unused-label", unused_label);
192 OPT("unused-parameter", unused_parameter);
193 OPT("unused-value", unused_value);
194 OPT("unused-variable", unused_variable);
195 OPT("write-strings", write_strings);
200 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);