1 /* messages.c - error reporter -
2 Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS 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 2, or (at your option)
11 GAS 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 GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #include <stdio.h> /* define stderr */
36 #endif /* NO_VARARGS */
37 #endif /* NO_STDARG */
40 * Despite the rest of the comments in this file, (FIXME-SOON),
41 * here is the current scheme for error messages etc:
43 * as_fatal() is used when gas is quite confused and
44 * continuing the assembly is pointless. In this case we
45 * exit immediately with error status.
47 * as_bad() is used to mark errors that result in what we
48 * presume to be a useless object file. Say, we ignored
49 * something that might have been vital. If we see any of
50 * these, assembly will continue to the end of the source,
51 * no object file will be produced, and we will terminate
52 * with error status. The new option, -Z, tells us to
53 * produce an object file anyway but we still exit with
54 * error status. The assumption here is that you don't want
55 * this object file but we could be wrong.
57 * as_warn() is used when we have an error from which we
58 * have a plausible error recovery. eg, masking the top
59 * bits of a constant that is longer than will fit in the
60 * destination. In this case we will continue to assemble
61 * the source, although we may have made a bad assumption,
62 * and we will produce an object file and return normal exit
63 * status (ie, no error). The new option -X tells us to
64 * treat all as_warn() errors as as_bad() errors. That is,
65 * no object file will be produced and we will exit with
66 * error status. The idea here is that we don't kill an
67 * entire make because of an error that we knew how to
68 * correct. On the other hand, sometimes you might want to
69 * stop the make at these points.
71 * as_tsktsk() is used when we see a minor error for which
72 * our error recovery action is almost certainly correct.
73 * In this case, we print a message and then assembly
74 * continues as though no error occurred.
80 JF: this is now bogus. We now print more standard error messages
81 that try to look like everyone else's.
83 We print the error message 1st, beginning in column 1.
84 All ancillary info starts in column 2 on lines after the
86 We try to print a location in logical and physical file
87 just after the main error text.
88 Caller then prints any appendices after that, begining all
89 lines with at least 1 space.
91 Optionally, we may die.
92 There is no need for a trailing '\n' in your error text format
93 because we supply one.
95 as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
97 as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
101 static int warning_count
; /* Count of number of warnings issued */
106 return (warning_count
);
109 /* Nonzero if we've hit a 'bad error', and should not write an obj file,
110 and exit with a nonzero error code */
112 static int error_count
;
117 return (error_count
);
124 * Like perror(3), but with more info.
127 as_perror (gripe
, filename
)
128 char *gripe
; /* Unpunctuated error theme. */
131 #ifndef HAVE_STRERROR
132 extern char *strerror ();
133 #endif /* HAVE_STRERROR */
136 fprintf (stderr
, gripe
, filename
);
137 fprintf (stderr
, ": %s\n", strerror (errno
));
138 errno
= 0; /* After reporting, clear it. */
142 * a s _ t s k t s k ()
144 * Send to stderr a string as a warning, and locate warning
146 * Please only use this for when we have some recovery action.
147 * Please explain in string (which may have '\n's) what recovery was done.
152 as_tsktsk (const char *Format
,...)
157 va_start (args
, Format
);
158 vfprintf (stderr
, Format
, args
);
160 (void) putc ('\n', stderr
);
166 as_tsktsk (Format
, va_alist
)
174 vfprintf (stderr
, Format
, args
);
176 (void) putc ('\n', stderr
);
181 as_tsktsk (Format
, args
)
185 _doprnt (Format
, &args
, stderr
);
186 (void) putc ('\n', stderr
);
190 #endif /* not NO_VARARGS */
191 #endif /* not NO_STDARG */
196 * Send to stderr a string as a warning, and locate warning
198 * Please only use this for when we have some recovery action.
199 * Please explain in string (which may have '\n's) what recovery was done.
204 as_warn (const char *Format
,...)
213 va_start (args
, Format
);
214 fprintf (stderr
, "Warning: ");
215 vsprintf (buffer
, Format
, args
);
216 fputs (buffer
, stderr
);
218 listing_warning (buffer
);
221 (void) putc ('\n', stderr
);
228 as_warn (Format
, va_alist
)
240 fprintf (stderr
, "Warning: ");
241 vsprintf (buffer
, Format
, args
);
242 fputs (buffer
, stderr
);
244 listing_warning (buffer
);
247 (void) putc ('\n', stderr
);
253 as_warn (Format
, args
)
256 /* -W supresses warning messages. */
261 _doprnt (Format
, &args
, stderr
);
262 (void) putc ('\n', stderr
);
267 #endif /* not NO_VARARGS */
268 #endif /* not NO_STDARG */
273 * Send to stderr a string as a warning, and locate warning in input file(s).
274 * Please us when there is no recovery, but we want to continue processing
275 * but not produce an object file.
276 * Please explain in string (which may have '\n's) what recovery was done.
281 as_bad (const char *Format
,...)
288 va_start (args
, Format
);
289 fprintf (stderr
, "Error: ");
291 vsprintf (buffer
, Format
, args
);
292 fputs (buffer
, stderr
);
294 listing_error (buffer
);
297 (void) putc ('\n', stderr
);
303 as_bad (Format
, va_alist
)
313 vsprintf (buffer
, Format
, args
);
314 fputs (buffer
, stderr
);
316 listing_error (buffer
);
320 (void) putc ('\n', stderr
);
325 as_bad (Format
, args
)
331 fprintf (stderr
, "Error: ");
332 _doprnt (Format
, &args
, stderr
);
333 (void) putc ('\n', stderr
);
337 #endif /* not NO_VARARGS */
338 #endif /* not NO_STDARG */
343 * Send to stderr a string as a fatal message, and print location of error in
345 * Please only use this for when we DON'T have some recovery action.
346 * It exit()s with a warning status.
351 as_fatal (const char *Format
,...)
356 va_start (args
, Format
);
357 fprintf (stderr
, "FATAL:");
358 vfprintf (stderr
, Format
, args
);
359 (void) putc ('\n', stderr
);
367 as_fatal (Format
, va_alist
)
375 fprintf (stderr
, "FATAL:");
376 vfprintf (stderr
, Format
, args
);
377 (void) putc ('\n', stderr
);
384 as_fatal (Format
, args
)
388 fprintf (stderr
, "FATAL:");
389 _doprnt (Format
, &args
, stderr
);
390 (void) putc ('\n', stderr
);
392 exit (33); /* What is a good exit status? */
395 #endif /* not NO_VARARGS */
396 #endif /* not NO_STDARG */
398 /* end of messages.c */
This page took 0.036961 seconds and 4 git commands to generate.