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 .fatal_errors = false,
41 .implicit_function_declaration = true,
46 .missing_declarations = false,
47 .missing_noreturn = false,
48 .missing_prototypes = false,
50 .nested_externs = false,
52 .old_style_definition = false,
55 .pointer_arith = true,
56 .redundant_decls = true,
58 .s_are_errors = false,
60 .sign_compare = false,
61 .strict_prototypes = true,
62 .switch_default = false,
65 .unknown_pragmas = true,
66 .unreachable_code = false,
67 .unused_function = false,
68 .unused_label = false,
69 .unused_parameter = false,
71 .unused_variable = false,
72 .write_strings = false
75 void set_warning_opt(const char *const opt)
82 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
88 #define OPTX(x) else if (strcmp(s, x) == 0)
89 #define SET(y) (void)(warning.y = state)
90 #define OPT(x, y) OPTX(x) SET(y)
92 /* Note: this switched on a lot more warnings than gcc's -Wall */
101 SET(implicit_function_declaration);
107 SET(redundant_decls);
111 SET(strict_prototypes);
113 SET(unknown_pragmas);
114 SET(unreachable_code);
115 SET(unused_function);
117 SET(unused_parameter);
119 SET(unused_variable);
121 OPT("address", address);
122 OPT("aggregate-return", aggregate_return);
123 OPT("attribute", attribute);
124 OPT("cast-qual", cast_qual);
125 OPT("char-subscripts", char_subscripts);
126 OPT("comment", comment);
127 OPT("conversion", conversion);
128 OPT("declaration-after-statement", declaration_after_statement);
129 OPT("deprecated-declarations", deprecated_declarations);
130 OPT("div-by-zero", div_by_zero);
131 OPT("empty-statement", empty_statement);
132 OPT("error", s_are_errors);
135 // TODO SET(function_end_without_return);
136 SET(empty_statement);
137 // TODO SET(incomplete_aggregate_init);
138 // TODO SET(missing_field_initializers);
139 // TODO SET(pointless_comparison);
140 SET(unused_parameter);
143 OPT("fatal-errors", fatal_errors);
144 OPT("float-equal", float_equal);
150 SET(implicit_function_declaration);
153 OPT("implicit-function-declaration", implicit_function_declaration);
154 OPT("implicit-int", implicit_int);
155 OPT("init-self", init_self);
156 OPT("long-long", long_long);
158 OPT("missing-declarations", missing_declarations);
159 OPT("missing-noreturn", missing_noreturn);
160 OPT("missing-prototypes", missing_prototypes);
161 OPT("multichar", multichar);
162 OPT("nested-externs", nested_externs);
163 OPT("nonnull", nonnull);
164 OPT("old-style-definition", old_style_definition);
165 OPT("packed", packed);
166 OPT("padded", padded);
167 OPT("pointer-arith", pointer_arith);
168 OPT("redundant-decls", redundant_decls);
169 OPT("return-type", return_type);
170 OPT("shadow", shadow);
171 OPT("sign-compare", sign_compare);
172 OPT("strict-prototypes", strict_prototypes);
173 OPT("switch-default", switch_default);
174 OPT("switch-enum", switch_enum);
175 OPT("traditional", traditional);
176 OPT("unknown-pragmas", unknown_pragmas);
177 OPT("unreachable-code", unreachable_code);
179 SET(unused_function);
181 SET(unused_parameter);
183 SET(unused_variable);
185 OPT("unused-function", unused_function);
186 OPT("unused-label", unused_label);
187 OPT("unused-parameter", unused_parameter);
188 OPT("unused-value", unused_value);
189 OPT("unused-variable", unused_variable);
190 OPT("write-strings", write_strings);
195 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);