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 .char_subscripts = true,
27 .declaration_after_statement = false,
28 .deprecated_declarations = true,
29 .empty_statement = false,
30 .fatal_errors = false,
33 .implicit_function_declaration = true,
37 .missing_declarations = false,
38 .missing_noreturn = false,
39 .missing_prototypes = false,
41 .nested_externs = false,
43 .pointer_arith = true,
44 .redundant_decls = true,
46 .s_are_errors = false,
48 .sign_compare = false,
49 .strict_prototypes = true,
50 .switch_default = false,
52 .unknown_pragmas = true,
53 .unreachable_code = false,
54 .unused_function = false,
55 .unused_label = false,
56 .unused_parameter = false,
58 .unused_variable = false,
59 .write_strings = false
62 void set_warning_opt(const char *const opt)
69 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
75 #define OPTX(x) else if (strcmp(s, x) == 0)
76 #define SET(y) (void)(warning.y = state)
77 #define OPT(x, y) OPTX(x) SET(y)
79 /* Note: this switched on a lot of more warnings than gcc's -Wall */
84 SET(implicit_function_declaration);
93 SET(strict_prototypes);
96 SET(unreachable_code);
99 SET(unused_parameter);
101 SET(unused_variable);
103 OPT("attribute", attribute);
104 OPT("char-subscripts", char_subscripts);
105 OPT("declaration-after-statement", declaration_after_statement);
106 OPT("deprecated-declarations", deprecated_declarations);
107 OPT("empty-statement", empty_statement);
108 OPT("error", s_are_errors);
111 // TODO SET(function_end_without_return);
112 SET(empty_statement);
113 // TODO SET(incomplete_aggregate_init);
114 // TODO SET(pointless_comparison);
115 SET(unused_parameter);
118 OPT("fatal-errors", fatal_errors);
119 OPT("float-equal", float_equal);
125 SET(implicit_function_declaration);
128 OPT("implicit-function-declaration", implicit_function_declaration);
129 OPT("implicit-int", implicit_int);
130 OPT("long-long", long_long);
132 OPT("missing-declarations", missing_declarations);
133 OPT("missing-noreturn", missing_noreturn);
134 OPT("missing-prototypes", missing_prototypes);
135 OPT("multichar", multichar);
136 OPT("nested-externs", nested_externs);
137 OPT("nonnull", nonnull);
138 OPT("pointer_arith", pointer_arith);
139 OPT("redundant-decls", redundant_decls);
140 OPT("return-type", return_type);
141 OPT("shadow", shadow);
142 OPT("sign-compare", sign_compare);
143 OPT("strict-prototypes", strict_prototypes);
144 OPT("switch-default", switch_default);
145 OPT("switch-enum", switch_enum);
146 OPT("unknown-pragmas", unknown_pragmas);
147 OPT("unreachable-code", unreachable_code);
149 SET(unused_function);
151 SET(unused_parameter);
153 SET(unused_variable);
155 OPT("unused-function", unused_function);
156 OPT("unused-label", unused_label);
157 OPT("unused-parameter", unused_parameter);
158 OPT("unused-value", unused_value);
159 OPT("unused-variable", unused_variable);
160 OPT("write-strings", write_strings);
165 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);