]>
git.saurik.com Git - bison.git/blob - src/complain.c
1 /* Declaration for error-reporting function for Bison.
3 Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006
4 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 /* Based on error.c and error.h,
22 written by David MacKenzie <djm@gnu.ai.mit.edu>. */
33 bool complaint_issued
;
37 /** Report an error message.
39 * \param loc the location, defaulting to the current file,
40 * or the program name.
41 * \param prefix put before the message (e.g., "warning").
42 * \param message the error message, a printf format string.
43 * \param args the arguments of the format string.
47 error_message (location
*loc
,
49 const char *message
, va_list args
)
52 location_print (stderr
, *loc
);
54 fputs (current_file
? current_file
: program_name
, stderr
);
58 fprintf (stderr
, "%s: ", prefix
);
60 vfprintf (stderr
, message
, args
);
66 /** Wrap error_message() with varargs handling. */
67 #define ERROR_MESSAGE(Loc, Prefix, Message) \
70 va_start (args, Message); \
71 error_message (Loc, Prefix, Message, args); \
75 /*--------------------------------.
76 | Report a warning, and proceed. |
77 `--------------------------------*/
80 set_warning_issued (void)
82 static bool warning_issued
= false;
83 if (!warning_issued
&& (warnings_flag
& warnings_error
))
85 fprintf (stderr
, "%s: warnings being treated as errors\n", program_name
);
86 complaint_issued
= true;
88 warning_issued
= true;
92 warn_at (location loc
, const char *message
, ...)
94 set_warning_issued ();
95 ERROR_MESSAGE (&loc
, _("warning"), message
);
99 warn (const char *message
, ...)
101 set_warning_issued ();
102 ERROR_MESSAGE (NULL
, _("warning"), message
);
106 /*-----------------------------------------------------------.
107 | An error has occurred, but we can proceed, and die later. |
108 `-----------------------------------------------------------*/
111 complain_at (location loc
, const char *message
, ...)
113 ERROR_MESSAGE (&loc
, NULL
, message
);
114 complaint_issued
= true;
118 complain (const char *message
, ...)
120 ERROR_MESSAGE (NULL
, NULL
, message
);
121 complaint_issued
= true;
125 /*-------------------------------------------------.
126 | A severe error has occurred, we cannot proceed. |
127 `-------------------------------------------------*/
130 fatal_at (location loc
, const char *message
, ...)
132 ERROR_MESSAGE (&loc
, _("fatal error"), message
);
137 fatal (const char *message
, ...)
139 ERROR_MESSAGE (NULL
, _("fatal error"), message
);