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,
36 .missing_declarations = false,
37 .missing_prototypes = false,
39 .nested_externs = false,
41 .redundant_decls = true,
43 .s_are_errors = false,
45 .sign_compare = false,
46 .strict_prototypes = true,
47 .switch_default = false,
48 .unknown_pragmas = true,
49 .unreachable_code = false,
50 .unused_function = false,
51 .unused_label = false,
52 .unused_parameter = false,
54 .unused_variable = false
57 void set_warning_opt(const char *const opt)
64 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
70 #define OPTX(x) else if (strcmp(s, x) == 0)
71 #define SET(y) (void)(warning.y = state)
72 #define OPT(x, y) OPTX(x) SET(y)
74 /* Note: this switched on a lot of more warnings than gcc's -Wall */
79 SET(implicit_function_declaration);
87 SET(strict_prototypes);
89 SET(unreachable_code);
92 SET(unused_parameter);
96 OPT("attribute", attribute);
97 OPT("char-subscripts", char_subscripts);
98 OPT("declaration-after-statement", declaration_after_statement);
99 OPT("deprecated-declarations", deprecated_declarations);
100 OPT("empty-statement", empty_statement);
101 OPT("error", s_are_errors);
104 // TODO SET(function_end_without_return);
105 SET(empty_statement);
106 // TODO SET(incomplete_aggregate_init);
107 // TODO SET(pointless_comparison);
108 SET(unused_parameter);
111 OPT("fatal-errors", fatal_errors);
112 OPT("float-equal", float_equal);
118 SET(implicit_function_declaration);
121 OPT("implicit-function-declaration", implicit_function_declaration);
122 OPT("implicit-int", implicit_int);
124 OPT("missing-declarations", missing_declarations);
125 OPT("missing-prototypes", missing_prototypes);
126 OPT("multichar", multichar);
127 OPT("nested-externs", nested_externs);
128 OPT("nonnull", nonnull);
129 OPT("redundant-decls", redundant_decls);
130 OPT("return-type", return_type);
131 OPT("shadow", shadow);
132 OPT("sign-compare", sign_compare);
133 OPT("strict-prototypes", strict_prototypes);
134 OPT("switch-default", switch_default);
135 OPT("unknown-pragmas", unknown_pragmas);
136 OPT("unreachable-code", unreachable_code);
138 SET(unused_function);
140 SET(unused_parameter);
142 SET(unused_variable);
144 OPT("unused-function", unused_function);
145 OPT("unused-label", unused_label);
146 OPT("unused-parameter", unused_parameter);
147 OPT("unused-value", unused_value);
148 OPT("unused-variable", unused_variable);
153 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);