]>
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>. */
32 /* The calling program should define program_name and set it to the
33 name of the executing program. */
34 extern char *program_name
;
36 bool complaint_issued
;
40 /** Report an error message.
42 * \param loc the location, defaulting to the current file,
43 * or the program name.
44 * \param prefix put before the message (e.g., "warning").
45 * \param message the error message, a printf format string.
46 * \param args the arguments of the format string.
50 error_message (location
*loc
,
52 const char *message
, va_list args
)
55 location_print (stderr
, *loc
);
57 fputs (current_file
? current_file
: program_name
, stderr
);
61 fprintf (stderr
, "%s: ", prefix
);
63 vfprintf (stderr
, message
, args
);
69 /** Wrap error_message() with varargs handling. */
70 #define ERROR_MESSAGE(Loc, Prefix, Message) \
73 va_start (args, Message); \
74 error_message (Loc, Prefix, Message, args); \
78 /*--------------------------------.
79 | Report a warning, and proceed. |
80 `--------------------------------*/
83 warn_at (location loc
, const char *message
, ...)
85 ERROR_MESSAGE (&loc
, _("warning"), message
);
89 warn (const char *message
, ...)
91 ERROR_MESSAGE (NULL
, _("warning"), message
);
95 /*-----------------------------------------------------------.
96 | An error has occurred, but we can proceed, and die later. |
97 `-----------------------------------------------------------*/
100 complain_at (location loc
, const char *message
, ...)
102 ERROR_MESSAGE (&loc
, NULL
, message
);
103 complaint_issued
= true;
107 complain (const char *message
, ...)
109 ERROR_MESSAGE (NULL
, NULL
, message
);
110 complaint_issued
= true;
114 /*-------------------------------------------------.
115 | A severe error has occurred, we cannot proceed. |
116 `-------------------------------------------------*/
119 fatal_at (location loc
, const char *message
, ...)
121 ERROR_MESSAGE (&loc
, _("fatal error"), message
);
126 fatal (const char *message
, ...)
128 ERROR_MESSAGE (NULL
, _("fatal error"), message
);