]> git.saurik.com Git - bison.git/blob - src/complain.h
style: move argument handling of -W into the diagnostics module
[bison.git] / src / complain.h
1 /* Declaration for error-reporting function for Bison.
2
3 Copyright (C) 2000-2002, 2006, 2009-2013 Free Software Foundation,
4 Inc.
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef COMPLAIN_H_
20 # define COMPLAIN_H_ 1
21
22 # include "location.h"
23
24 /* Sub-messages indent. */
25 # define SUB_INDENT (4)
26
27 /*-------------.
28 | --warnings. |
29 `-------------*/
30
31 /** The bits assigned to each warning type. */
32 typedef enum
33 {
34 warning_midrule_values, /**< Unset or unused midrule values. */
35 warning_yacc, /**< POSIXME. */
36 warning_conflicts_sr, /**< S/R conflicts. */
37 warning_conflicts_rr, /**< R/R conflicts. */
38 warning_deprecated, /**< Obsolete constructs. */
39 warning_precedence, /**< Useless precedence and associativity. */
40 warning_other, /**< All other warnings. */
41
42 warnings_size /**< The number of warnings. Must be last. */
43 } warning_bit;
44
45 /** Whether -Werror was set. */
46 extern bool warnings_are_errors;
47
48 /** Decode a single argument from -W.
49 *
50 * \param arg the subarguments to decode.
51 * If null, then activate all the flags.
52 * \param no length of the potential "no-" prefix.
53 * Can be 0 or 3. If 3, negate the action of the subargument.
54 * \param err length of a potential "error=".
55 * Can be 0 or 6. If 6, treat the subargument as a CATEGORY.
56 *
57 * If VALUE != 0 then KEY sets flags and no-KEY clears them.
58 * If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all
59 * flags from \c all. Thus no-none = all and no-all = none.
60 */
61 void warning_argmatch (char const *arg, size_t no, size_t err);
62
63 /** Decode a comma-separated list of arguments from -W.
64 *
65 * \param args comma separated list of effective subarguments to decode.
66 * If 0, then activate all the flags.
67 */
68 void warnings_argmatch (char *args);
69
70
71 /*-----------.
72 | complain. |
73 `-----------*/
74
75 /** Initialize this module. */
76 void complain_init (void);
77
78 typedef enum
79 {
80 /**< Issue no warnings. */
81 Wnone = 0,
82
83 Wmidrule_values = 1 << warning_midrule_values,
84 Wyacc = 1 << warning_yacc,
85 Wconflicts_sr = 1 << warning_conflicts_sr,
86 Wconflicts_rr = 1 << warning_conflicts_rr,
87 Wdeprecated = 1 << warning_deprecated,
88 Wprecedence = 1 << warning_precedence,
89 Wother = 1 << warning_other,
90
91 Werror = 1 << 10, /** This bit is no longer used. */
92
93 complaint = 1 << 11, /**< All complaints. */
94 fatal = 1 << 12, /**< All fatal errors. */
95 silent = 1 << 13, /**< Do not display the warning type. */
96 no_caret = 1 << 14, /**< Do not display caret location. */
97
98 /**< All above warnings. */
99 Wall = ~complaint & ~fatal & ~silent
100 } warnings;
101
102
103 /** Make a complaint, with maybe a location. */
104 void complain (location const *loc, warnings flags, char const *message, ...)
105 __attribute__ ((__format__ (__printf__, 3, 4)));
106
107 /** Likewise, but with an \a argc/argv interface. */
108 void complain_args (location const *loc, warnings w, unsigned *indent,
109 int argc, char *arg[]);
110
111 /** Make a complaint with location and some indentation. */
112 void complain_indent (location const *loc, warnings flags, unsigned *indent,
113 char const *message, ...)
114 __attribute__ ((__format__ (__printf__, 4, 5)));
115
116
117 /** Report an obsolete syntax, suggest the updated one. */
118 void deprecated_directive (location const *loc,
119 char const *obsolete, char const *updated);
120
121 /** Warnings treated as errors shouldn't stop the execution as regular errors
122 should (because due to their nature, it is safe to go on). Thus, there are
123 three possible execution statuses. */
124 typedef enum
125 {
126 status_none,
127 status_warning_as_error,
128 status_complaint
129 } err_status;
130
131 /** Whether an error was reported. */
132 extern err_status complaint_status;
133
134 #endif /* !COMPLAIN_H_ */