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,
27 .char_subscripts = true,
29 .declaration_after_statement = false,
30 .deprecated_declarations = true,
32 .empty_statement = false,
33 .fatal_errors = false,
36 .implicit_function_declaration = true,
40 .missing_declarations = false,
41 .missing_noreturn = false,
42 .missing_prototypes = false,
44 .nested_externs = false,
46 .pointer_arith = true,
47 .redundant_decls = true,
49 .s_are_errors = false,
51 .sign_compare = false,
52 .strict_prototypes = true,
53 .switch_default = false,
55 .unknown_pragmas = true,
56 .unreachable_code = false,
57 .unused_function = false,
58 .unused_label = false,
59 .unused_parameter = false,
61 .unused_variable = false,
62 .write_strings = false
65 void set_warning_opt(const char *const opt)
72 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
78 #define OPTX(x) else if (strcmp(s, x) == 0)
79 #define SET(y) (void)(warning.y = state)
80 #define OPT(x, y) OPTX(x) SET(y)
82 /* Note: this switched on a lot of more warnings than gcc's -Wall */
87 SET(implicit_function_declaration);
96 SET(strict_prototypes);
99 SET(unreachable_code);
100 SET(unused_function);
102 SET(unused_parameter);
104 SET(unused_variable);
106 OPT("aggregate-return", aggregate_return);
107 OPT("attribute", attribute);
108 OPT("char-subscripts", char_subscripts);
109 OPT("cast-qual", cast_qual);
110 OPT("declaration-after-statement", declaration_after_statement);
111 OPT("deprecated-declarations", deprecated_declarations);
112 OPT("div_by_zero", div_by_zero);
113 OPT("empty-statement", empty_statement);
114 OPT("error", s_are_errors);
117 // TODO SET(function_end_without_return);
118 SET(empty_statement);
119 // TODO SET(incomplete_aggregate_init);
120 // TODO SET(pointless_comparison);
121 SET(unused_parameter);
124 OPT("fatal-errors", fatal_errors);
125 OPT("float-equal", float_equal);
131 SET(implicit_function_declaration);
134 OPT("implicit-function-declaration", implicit_function_declaration);
135 OPT("implicit-int", implicit_int);
136 OPT("long-long", long_long);
138 OPT("missing-declarations", missing_declarations);
139 OPT("missing-noreturn", missing_noreturn);
140 OPT("missing-prototypes", missing_prototypes);
141 OPT("multichar", multichar);
142 OPT("nested-externs", nested_externs);
143 OPT("nonnull", nonnull);
144 OPT("pointer_arith", pointer_arith);
145 OPT("redundant-decls", redundant_decls);
146 OPT("return-type", return_type);
147 OPT("shadow", shadow);
148 OPT("sign-compare", sign_compare);
149 OPT("strict-prototypes", strict_prototypes);
150 OPT("switch-default", switch_default);
151 OPT("switch-enum", switch_enum);
152 OPT("unknown-pragmas", unknown_pragmas);
153 OPT("unreachable-code", unreachable_code);
155 SET(unused_function);
157 SET(unused_parameter);
159 SET(unused_variable);
161 OPT("unused-function", unused_function);
162 OPT("unused-label", unused_label);
163 OPT("unused-parameter", unused_parameter);
164 OPT("unused-value", unused_value);
165 OPT("unused-variable", unused_variable);
166 OPT("write-strings", write_strings);
171 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);