2 * This file is part of cparser.
3 * Copyright (C) 2007-2009 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 .uninitialized = true,
68 .unknown_pragmas = true,
69 .unreachable_code = false,
70 .unused_function = false,
71 .unused_label = false,
72 .unused_parameter = false,
74 .unused_variable = false,
75 .write_strings = false
78 void set_warning_opt(const char *const opt)
85 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
91 #define OPTX(x) else if (strcmp(s, x) == 0)
92 #define SET(y) (void)(warning.y = state)
93 #define OPT(x, y) OPTX(x) SET(y)
95 /* Note: this switched on a lot more warnings than gcc's -Wall */
100 SET(char_subscripts);
102 SET(empty_statement);
104 SET(implicit_function_declaration);
111 SET(redundant_decls);
115 SET(strict_prototypes);
118 SET(unknown_pragmas);
119 SET(unreachable_code);
120 SET(unused_function);
122 SET(unused_parameter);
124 SET(unused_variable);
126 OPT("address", address);
127 OPT("aggregate-return", aggregate_return);
128 OPT("attribute", attribute);
129 OPT("cast-qual", cast_qual);
130 OPT("char-subscripts", char_subscripts);
131 OPT("comment", comment);
132 OPT("conversion", conversion);
133 OPT("declaration-after-statement", declaration_after_statement);
134 OPT("deprecated-declarations", deprecated_declarations);
135 OPT("div-by-zero", div_by_zero);
136 OPT("empty-statement", empty_statement);
137 OPT("error", s_are_errors);
138 OPT("error-implicit-function-declaration", error_implicit_function_declaration);
141 // TODO SET(function_end_without_return);
142 SET(empty_statement);
143 // TODO SET(incomplete_aggregate_init);
144 // TODO SET(missing_field_initializers);
145 // TODO SET(pointless_comparison);
146 SET(unused_parameter);
149 OPT("fatal-errors", fatal_errors);
150 OPT("float-equal", float_equal);
156 SET(implicit_function_declaration);
159 OPT("implicit-function-declaration", implicit_function_declaration);
160 OPT("implicit-int", implicit_int);
161 OPT("init-self", init_self);
162 OPT("long-long", long_long);
164 OPT("missing-declarations", missing_declarations);
165 OPT("missing-noreturn", missing_noreturn);
166 OPT("missing-prototypes", missing_prototypes);
167 OPT("multichar", multichar);
168 OPT("nested-externs", nested_externs);
169 OPT("nonnull", nonnull);
170 OPT("old-style-definition", old_style_definition);
171 OPT("packed", packed);
172 OPT("padded", padded);
173 OPT("parentheses", parentheses);
174 OPT("pointer-arith", pointer_arith);
175 OPT("redundant-decls", redundant_decls);
176 OPT("return-type", return_type);
177 OPT("shadow", shadow);
178 OPT("sign-compare", sign_compare);
179 OPT("strict-prototypes", strict_prototypes);
180 OPT("switch-default", switch_default);
181 OPT("switch-enum", switch_enum);
182 OPT("traditional", traditional);
183 OPT("uninitialized", uninitialized);
184 OPT("unknown-pragmas", unknown_pragmas);
185 OPT("unreachable-code", unreachable_code);
187 SET(unused_function);
189 SET(unused_parameter);
191 SET(unused_variable);
193 OPT("unused-function", unused_function);
194 OPT("unused-label", unused_label);
195 OPT("unused-parameter", unused_parameter);
196 OPT("unused-value", unused_value);
197 OPT("unused-variable", unused_variable);
198 OPT("write-strings", write_strings);
203 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);