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 .aggregate_return = false,
29 .char_subscripts = true,
32 .declaration_after_statement = false,
33 .deprecated_declarations = true,
35 .empty_statement = false,
36 .fatal_errors = false,
39 .implicit_function_declaration = true,
44 .missing_declarations = false,
45 .missing_noreturn = false,
46 .missing_prototypes = false,
48 .nested_externs = false,
50 .old_style_definition = false,
53 .pointer_arith = true,
54 .redundant_decls = true,
56 .s_are_errors = false,
58 .sign_compare = false,
59 .strict_prototypes = true,
60 .switch_default = false,
63 .unknown_pragmas = true,
64 .unreachable_code = false,
65 .unused_function = false,
66 .unused_label = false,
67 .unused_parameter = false,
69 .unused_variable = false,
70 .write_strings = false
73 void set_warning_opt(const char *const opt)
80 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
86 #define OPTX(x) else if (strcmp(s, x) == 0)
87 #define SET(y) (void)(warning.y = state)
88 #define OPT(x, y) OPTX(x) SET(y)
90 /* Note: this switched on a lot of more warnings than gcc's -Wall */
97 SET(implicit_function_declaration);
103 SET(redundant_decls);
107 SET(strict_prototypes);
109 SET(unknown_pragmas);
110 SET(unreachable_code);
111 SET(unused_function);
113 SET(unused_parameter);
115 SET(unused_variable);
117 OPT("address", address);
118 OPT("aggregate-return", aggregate_return);
119 OPT("attribute", attribute);
120 OPT("cast-qual", cast_qual);
121 OPT("char-subscripts", char_subscripts);
122 OPT("comment", comment);
123 OPT("conversion", conversion);
124 OPT("declaration-after-statement", declaration_after_statement);
125 OPT("deprecated-declarations", deprecated_declarations);
126 OPT("div-by-zero", div_by_zero);
127 OPT("empty-statement", empty_statement);
128 OPT("error", s_are_errors);
131 // TODO SET(function_end_without_return);
132 SET(empty_statement);
133 // TODO SET(incomplete_aggregate_init);
134 // TODO SET(missing_field_initializers);
135 // TODO SET(pointless_comparison);
136 SET(unused_parameter);
139 OPT("fatal-errors", fatal_errors);
140 OPT("float-equal", float_equal);
146 SET(implicit_function_declaration);
149 OPT("implicit-function-declaration", implicit_function_declaration);
150 OPT("implicit-int", implicit_int);
151 OPT("init-self", init_self);
152 OPT("long-long", long_long);
154 OPT("missing-declarations", missing_declarations);
155 OPT("missing-noreturn", missing_noreturn);
156 OPT("missing-prototypes", missing_prototypes);
157 OPT("multichar", multichar);
158 OPT("nested-externs", nested_externs);
159 OPT("nonnull", nonnull);
160 OPT("old-style-definition", old_style_definition);
161 OPT("packed", packed);
162 OPT("padded", padded);
163 OPT("pointer-arith", pointer_arith);
164 OPT("redundant-decls", redundant_decls);
165 OPT("return-type", return_type);
166 OPT("shadow", shadow);
167 OPT("sign-compare", sign_compare);
168 OPT("strict-prototypes", strict_prototypes);
169 OPT("switch-default", switch_default);
170 OPT("switch-enum", switch_enum);
171 OPT("traditional", traditional);
172 OPT("unknown-pragmas", unknown_pragmas);
173 OPT("unreachable-code", unreachable_code);
175 SET(unused_function);
177 SET(unused_parameter);
179 SET(unused_variable);
181 OPT("unused-function", unused_function);
182 OPT("unused-label", unused_label);
183 OPT("unused-parameter", unused_parameter);
184 OPT("unused-value", unused_value);
185 OPT("unused-variable", unused_variable);
186 OPT("write-strings", write_strings);
191 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);