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
25 .aggregate_return = false,
28 .char_subscripts = true,
31 .declaration_after_statement = false,
32 .deprecated_declarations = true,
34 .empty_statement = false,
35 .fatal_errors = false,
38 .implicit_function_declaration = true,
43 .missing_declarations = false,
44 .missing_noreturn = false,
45 .missing_prototypes = false,
47 .nested_externs = false,
49 .old_style_definition = false,
52 .pointer_arith = true,
53 .redundant_decls = true,
55 .s_are_errors = false,
57 .sign_compare = false,
58 .strict_prototypes = true,
59 .switch_default = false,
62 .unknown_pragmas = true,
63 .unreachable_code = false,
64 .unused_function = false,
65 .unused_label = false,
66 .unused_parameter = false,
68 .unused_variable = false,
69 .write_strings = false
72 void set_warning_opt(const char *const opt)
79 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
85 #define OPTX(x) else if (strcmp(s, x) == 0)
86 #define SET(y) (void)(warning.y = state)
87 #define OPT(x, y) OPTX(x) SET(y)
89 /* Note: this switched on a lot of more warnings than gcc's -Wall */
95 SET(implicit_function_declaration);
101 SET(redundant_decls);
105 SET(strict_prototypes);
107 SET(unknown_pragmas);
108 SET(unreachable_code);
109 SET(unused_function);
111 SET(unused_parameter);
113 SET(unused_variable);
115 OPT("aggregate-return", aggregate_return);
116 OPT("attribute", attribute);
117 OPT("cast-qual", cast_qual);
118 OPT("char-subscripts", char_subscripts);
119 OPT("comment", comment);
120 OPT("conversion", conversion);
121 OPT("declaration-after-statement", declaration_after_statement);
122 OPT("deprecated-declarations", deprecated_declarations);
123 OPT("div-by-zero", div_by_zero);
124 OPT("empty-statement", empty_statement);
125 OPT("error", s_are_errors);
128 // TODO SET(function_end_without_return);
129 SET(empty_statement);
130 // TODO SET(incomplete_aggregate_init);
131 // TODO SET(missing_field_initializers);
132 // TODO SET(pointless_comparison);
133 SET(unused_parameter);
136 OPT("fatal-errors", fatal_errors);
137 OPT("float-equal", float_equal);
143 SET(implicit_function_declaration);
146 OPT("implicit-function-declaration", implicit_function_declaration);
147 OPT("implicit-int", implicit_int);
148 OPT("init-self", init_self);
149 OPT("long-long", long_long);
151 OPT("missing-declarations", missing_declarations);
152 OPT("missing-noreturn", missing_noreturn);
153 OPT("missing-prototypes", missing_prototypes);
154 OPT("multichar", multichar);
155 OPT("nested-externs", nested_externs);
156 OPT("nonnull", nonnull);
157 OPT("old-style-definition", old_style_definition);
158 OPT("packed", packed);
159 OPT("padded", padded);
160 OPT("pointer-arith", pointer_arith);
161 OPT("redundant-decls", redundant_decls);
162 OPT("return-type", return_type);
163 OPT("shadow", shadow);
164 OPT("sign-compare", sign_compare);
165 OPT("strict-prototypes", strict_prototypes);
166 OPT("switch-default", switch_default);
167 OPT("switch-enum", switch_enum);
168 OPT("traditional", traditional);
169 OPT("unknown-pragmas", unknown_pragmas);
170 OPT("unreachable-code", unreachable_code);
172 SET(unused_function);
174 SET(unused_parameter);
176 SET(unused_variable);
178 OPT("unused-function", unused_function);
179 OPT("unused-label", unused_label);
180 OPT("unused-parameter", unused_parameter);
181 OPT("unused-value", unused_value);
182 OPT("unused-variable", unused_variable);
183 OPT("write-strings", write_strings);
188 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);