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,
30 .declaration_after_statement = false,
31 .deprecated_declarations = true,
33 .empty_statement = false,
34 .fatal_errors = false,
37 .implicit_function_declaration = true,
42 .missing_declarations = false,
43 .missing_noreturn = false,
44 .missing_prototypes = false,
46 .nested_externs = false,
48 .pointer_arith = true,
49 .redundant_decls = true,
51 .s_are_errors = false,
53 .sign_compare = false,
54 .strict_prototypes = true,
55 .switch_default = false,
57 .unknown_pragmas = true,
58 .unreachable_code = false,
59 .unused_function = false,
60 .unused_label = false,
61 .unused_parameter = false,
63 .unused_variable = false,
64 .write_strings = false
67 void set_warning_opt(const char *const opt)
74 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
80 #define OPTX(x) else if (strcmp(s, x) == 0)
81 #define SET(y) (void)(warning.y = state)
82 #define OPT(x, y) OPTX(x) SET(y)
84 /* Note: this switched on a lot of more warnings than gcc's -Wall */
90 SET(implicit_function_declaration);
100 SET(strict_prototypes);
102 SET(unknown_pragmas);
103 SET(unreachable_code);
104 SET(unused_function);
106 SET(unused_parameter);
108 SET(unused_variable);
110 OPT("aggregate-return", aggregate_return);
111 OPT("attribute", attribute);
112 OPT("cast-qual", cast_qual);
113 OPT("char-subscripts", char_subscripts);
114 OPT("comment", comment);
115 OPT("declaration-after-statement", declaration_after_statement);
116 OPT("deprecated-declarations", deprecated_declarations);
117 OPT("div_by_zero", div_by_zero);
118 OPT("empty-statement", empty_statement);
119 OPT("error", s_are_errors);
122 // TODO SET(function_end_without_return);
123 SET(empty_statement);
124 // TODO SET(incomplete_aggregate_init);
125 // TODO SET(missing_field_initializers);
126 // TODO SET(pointless_comparison);
127 SET(unused_parameter);
130 OPT("fatal-errors", fatal_errors);
131 OPT("float-equal", float_equal);
137 SET(implicit_function_declaration);
140 OPT("implicit-function-declaration", implicit_function_declaration);
141 OPT("implicit-int", implicit_int);
142 OPT("init-self", init_self);
143 OPT("long-long", long_long);
145 OPT("missing-declarations", missing_declarations);
146 OPT("missing-noreturn", missing_noreturn);
147 OPT("missing-prototypes", missing_prototypes);
148 OPT("multichar", multichar);
149 OPT("nested-externs", nested_externs);
150 OPT("nonnull", nonnull);
151 OPT("pointer_arith", pointer_arith);
152 OPT("redundant-decls", redundant_decls);
153 OPT("return-type", return_type);
154 OPT("shadow", shadow);
155 OPT("sign-compare", sign_compare);
156 OPT("strict-prototypes", strict_prototypes);
157 OPT("switch-default", switch_default);
158 OPT("switch-enum", switch_enum);
159 OPT("unknown-pragmas", unknown_pragmas);
160 OPT("unreachable-code", unreachable_code);
162 SET(unused_function);
164 SET(unused_parameter);
166 SET(unused_variable);
168 OPT("unused-function", unused_function);
169 OPT("unused-label", unused_label);
170 OPT("unused-parameter", unused_parameter);
171 OPT("unused-value", unused_value);
172 OPT("unused-variable", unused_variable);
173 OPT("write-strings", write_strings);
178 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);