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 .pointer_arith = true,
50 .redundant_decls = true,
52 .s_are_errors = false,
54 .sign_compare = false,
55 .strict_prototypes = true,
56 .switch_default = false,
59 .unknown_pragmas = true,
60 .unreachable_code = false,
61 .unused_function = false,
62 .unused_label = false,
63 .unused_parameter = false,
65 .unused_variable = false,
66 .write_strings = false
69 void set_warning_opt(const char *const opt)
76 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
82 #define OPTX(x) else if (strcmp(s, x) == 0)
83 #define SET(y) (void)(warning.y = state)
84 #define OPT(x, y) OPTX(x) SET(y)
86 /* Note: this switched on a lot of more warnings than gcc's -Wall */
92 SET(implicit_function_declaration);
102 SET(strict_prototypes);
104 SET(unknown_pragmas);
105 SET(unreachable_code);
106 SET(unused_function);
108 SET(unused_parameter);
110 SET(unused_variable);
112 OPT("aggregate-return", aggregate_return);
113 OPT("attribute", attribute);
114 OPT("cast-qual", cast_qual);
115 OPT("char-subscripts", char_subscripts);
116 OPT("comment", comment);
117 OPT("conversion", conversion);
118 OPT("declaration-after-statement", declaration_after_statement);
119 OPT("deprecated-declarations", deprecated_declarations);
120 OPT("div_by_zero", div_by_zero);
121 OPT("empty-statement", empty_statement);
122 OPT("error", s_are_errors);
125 // TODO SET(function_end_without_return);
126 SET(empty_statement);
127 // TODO SET(incomplete_aggregate_init);
128 // TODO SET(missing_field_initializers);
129 // TODO SET(pointless_comparison);
130 SET(unused_parameter);
133 OPT("fatal-errors", fatal_errors);
134 OPT("float-equal", float_equal);
140 SET(implicit_function_declaration);
143 OPT("implicit-function-declaration", implicit_function_declaration);
144 OPT("implicit-int", implicit_int);
145 OPT("init-self", init_self);
146 OPT("long-long", long_long);
148 OPT("missing-declarations", missing_declarations);
149 OPT("missing-noreturn", missing_noreturn);
150 OPT("missing-prototypes", missing_prototypes);
151 OPT("multichar", multichar);
152 OPT("nested-externs", nested_externs);
153 OPT("nonnull", nonnull);
154 OPT("pointer_arith", pointer_arith);
155 OPT("redundant-decls", redundant_decls);
156 OPT("return-type", return_type);
157 OPT("shadow", shadow);
158 OPT("sign-compare", sign_compare);
159 OPT("strict-prototypes", strict_prototypes);
160 OPT("switch-default", switch_default);
161 OPT("switch-enum", switch_enum);
162 OPT("traditional", traditional);
163 OPT("unknown-pragmas", unknown_pragmas);
164 OPT("unreachable-code", unreachable_code);
166 SET(unused_function);
168 SET(unused_parameter);
170 SET(unused_variable);
172 OPT("unused-function", unused_function);
173 OPT("unused-label", unused_label);
174 OPT("unused-parameter", unused_parameter);
175 OPT("unused-value", unused_value);
176 OPT("unused-variable", unused_variable);
177 OPT("write-strings", write_strings);
182 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);