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,
30 .empty_statement = false,
31 .fatal_errors = false,
34 .implicit_function_declaration = true,
38 .missing_declarations = false,
39 .missing_noreturn = false,
40 .missing_prototypes = false,
42 .nested_externs = false,
44 .pointer_arith = true,
45 .redundant_decls = true,
47 .s_are_errors = false,
49 .sign_compare = false,
50 .strict_prototypes = true,
51 .switch_default = false,
53 .unknown_pragmas = true,
54 .unreachable_code = false,
55 .unused_function = false,
56 .unused_label = false,
57 .unused_parameter = false,
59 .unused_variable = false,
60 .write_strings = false
63 void set_warning_opt(const char *const opt)
70 if (s[0] == 'n' && s[1] == 'o' && s[2] == '-') {
76 #define OPTX(x) else if (strcmp(s, x) == 0)
77 #define SET(y) (void)(warning.y = state)
78 #define OPT(x, y) OPTX(x) SET(y)
80 /* Note: this switched on a lot of more warnings than gcc's -Wall */
85 SET(implicit_function_declaration);
94 SET(strict_prototypes);
97 SET(unreachable_code);
100 SET(unused_parameter);
102 SET(unused_variable);
104 OPT("attribute", attribute);
105 OPT("char-subscripts", char_subscripts);
106 OPT("declaration-after-statement", declaration_after_statement);
107 OPT("deprecated-declarations", deprecated_declarations);
108 OPT("div_by_zero", div_by_zero);
109 OPT("empty-statement", empty_statement);
110 OPT("error", s_are_errors);
113 // TODO SET(function_end_without_return);
114 SET(empty_statement);
115 // TODO SET(incomplete_aggregate_init);
116 // TODO SET(pointless_comparison);
117 SET(unused_parameter);
120 OPT("fatal-errors", fatal_errors);
121 OPT("float-equal", float_equal);
127 SET(implicit_function_declaration);
130 OPT("implicit-function-declaration", implicit_function_declaration);
131 OPT("implicit-int", implicit_int);
132 OPT("long-long", long_long);
134 OPT("missing-declarations", missing_declarations);
135 OPT("missing-noreturn", missing_noreturn);
136 OPT("missing-prototypes", missing_prototypes);
137 OPT("multichar", multichar);
138 OPT("nested-externs", nested_externs);
139 OPT("nonnull", nonnull);
140 OPT("pointer_arith", pointer_arith);
141 OPT("redundant-decls", redundant_decls);
142 OPT("return-type", return_type);
143 OPT("shadow", shadow);
144 OPT("sign-compare", sign_compare);
145 OPT("strict-prototypes", strict_prototypes);
146 OPT("switch-default", switch_default);
147 OPT("switch-enum", switch_enum);
148 OPT("unknown-pragmas", unknown_pragmas);
149 OPT("unreachable-code", unreachable_code);
151 SET(unused_function);
153 SET(unused_parameter);
155 SET(unused_variable);
157 OPT("unused-function", unused_function);
158 OPT("unused-label", unused_label);
159 OPT("unused-parameter", unused_parameter);
160 OPT("unused-value", unused_value);
161 OPT("unused-variable", unused_variable);
162 OPT("write-strings", write_strings);
167 fprintf(stderr, "warning: ignoring unknown option -W%s\n", opt);