]> git.saurik.com Git - bison.git/blob - src/complain.h
carets: properly display when no line feed is present
[bison.git] / src / complain.h
1 /* Declaration for error-reporting function for Bison.
2
3 Copyright (C) 2000-2002, 2006, 2009-2012 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 typedef enum
32 {
33 Wnone = 0, /**< Issue no warnings. */
34 Wmidrule_values = 1 << 0, /**< Unset or unused midrule values. */
35 Wyacc = 1 << 1, /**< POSIXME. */
36 Wconflicts_sr = 1 << 2, /**< S/R conflicts. */
37 Wconflicts_rr = 1 << 3, /**< R/R conflicts. */
38 Wdeprecated = 1 << 4, /**< Obsolete constructs. */
39 Wother = 1 << 5, /**< All other warnings. */
40
41 Werror = 1 << 10, /** This bit is no longer used. */
42
43 complaint = 1 << 11, /**< All complaints. */
44 fatal = 1 << 12, /**< All fatal errors. */
45 silent = 1 << 13, /**< Do not display the warning type. */
46 no_caret = 1 << 14, /**< Do not display caret location. */
47
48 /**< All above warnings. */
49 Wall = ~complaint & ~fatal & ~silent
50 } warnings;
51
52 /** What warnings are issued. */
53 extern warnings warnings_flag;
54
55 /** What warnings are made errors. */
56 extern warnings errors_flag;
57
58 /** Display a "[-Wyacc]" like message on stderr. */
59 void warnings_print_categories (warnings warn_flags);
60
61 /** Make a complaint, with maybe a location. */
62 void complain (location const *loc, warnings flags, char const *message, ...)
63 __attribute__ ((__format__ (__printf__, 3, 4)));
64
65 /** Likewise, but with an \a argc/argv interface. */
66 void complain_args (location const *loc, warnings w, unsigned *indent,
67 int argc, char *arg[]);
68
69 /** Make a complaint with location and some indentation. */
70 void complain_indent (location const *loc, warnings flags, unsigned *indent,
71 char const *message, ...)
72 __attribute__ ((__format__ (__printf__, 4, 5)));
73
74
75 /** Report an obsolete syntax, suggest the updated one. */
76 void deprecated_directive (location const *loc,
77 char const *obsolete, char const *updated);
78
79 /** Warnings treated as errors shouldn't stop the execution as regular errors
80 should (because due to their nature, it is safe to go on). Thus, there are
81 three possible execution statuses. */
82 typedef enum
83 {
84 status_none,
85 status_warning_as_error,
86 status_complaint
87 } err_status;
88
89 /** Whether an error was reported. */
90 extern err_status complaint_status;
91
92 #endif /* !COMPLAIN_H_ */