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 */
30 #endif /* NO_VARARGS */
31 #endif /* NO_STDARG */
34 * Despite the rest of the comments in this file, (FIXME-SOON),
35 * here is the current scheme for error messages etc:
37 * as_fatal() is used when gas is quite confused and
38 * continuing the assembly is pointless. In this case we
39 * exit immediately with error status.
41 * as_bad() is used to mark errors that result in what we
42 * presume to be a useless object file. Say, we ignored
43 * something that might have been vital. If we see any of
44 * these, assembly will continue to the end of the source,
45 * no object file will be produced, and we will terminate
46 * with error status. The new option, -Z, tells us to
47 * produce an object file anyway but we still exit with
48 * error status. The assumption here is that you don't want
49 * this object file but we could be wrong.
51 * as_warn() is used when we have an error from which we
52 * have a plausible error recovery. eg, masking the top
53 * bits of a constant that is longer than will fit in the
54 * destination. In this case we will continue to assemble
55 * the source, although we may have made a bad assumption,
56 * and we will produce an object file and return normal exit
57 * status (ie, no error). The new option -X tells us to
58 * treat all as_warn() errors as as_bad() errors. That is,
59 * no object file will be produced and we will exit with
60 * error status. The idea here is that we don't kill an
61 * entire make because of an error that we knew how to
62 * correct. On the other hand, sometimes you might want to
63 * stop the make at these points.
65 * as_tsktsk() is used when we see a minor error for which
66 * our error recovery action is almost certainly correct.
67 * In this case, we print a message and then assembly
68 * continues as though no error occurred.
74 JF: this is now bogus. We now print more standard error messages
75 that try to look like everyone else's.
77 We print the error message 1st, beginning in column 1.
78 All ancillary info starts in column 2 on lines after the
80 We try to print a location in logical and physical file
81 just after the main error text.
82 Caller then prints any appendices after that, begining all
83 lines with at least 1 space.
85 Optionally, we may die.
86 There is no need for a trailing '\n' in your error text format
87 because we supply one.
89 as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
91 as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
95 static int warning_count
; /* Count of number of warnings issued */
98 return(warning_count
);
101 /* Nonzero if we've hit a 'bad error', and should not write an obj file,
102 and exit with a nonzero error code */
104 static int error_count
;
114 * Like perror(3), but with more info.
116 void as_perror(gripe
, filename
)
117 char *gripe
; /* Unpunctuated error theme. */
120 #ifndef HAVE_STRERROR
121 extern char *strerror();
122 #endif /* HAVE_STRERROR */
125 fprintf(stderr
, gripe
, filename
);
126 fprintf(stderr
, "%s.\n", strerror(errno
));
127 errno
= 0; /* After reporting, clear it. */
131 * a s _ t s k t s k ()
133 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
135 * Please only use this for when we have some recovery action.
136 * Please explain in string (which may have '\n's) what recovery was done.
140 void as_tsktsk(const char *Format
, ...)
145 va_start(args
, Format
);
146 vfprintf(stderr
, Format
, args
);
148 (void) putc('\n', stderr
);
152 void as_tsktsk(Format
,va_alist
)
160 vfprintf(stderr
, Format
, args
);
162 (void) putc('\n', stderr
);
166 as_tsktsk(Format
,args
)
170 _doprnt (Format
, &args
, stderr
);
171 (void)putc ('\n', stderr
);
174 #endif /* not NO_VARARGS */
175 #endif /* not NO_STDARG */
180 * Send to stderr a string as a warning, and locate warning
182 * Please only use this for when we have some recovery action.
183 * Please explain in string (which may have '\n's) what recovery was done.
187 void as_warn(const char *Format
, ...)
195 va_start(args
, Format
);
196 fprintf(stderr
,"Warning: ");
197 vsprintf(buffer
, Format
, args
);
198 fputs (buffer
, stderr
);
200 listing_warning(buffer
);
203 (void) putc('\n', stderr
);
208 void as_warn(Format
,va_alist
)
219 fprintf(stderr
,"Warning: ");
220 vsprintf(buffer
, Format
, args
);
221 fputs (buffer
, stderr
);
223 listing_warning(buffer
);
226 (void) putc('\n', stderr
);
234 /* -W supresses warning messages. */
235 if (! flagseen
['W']) {
238 _doprnt (Format
, &args
, stderr
);
239 (void)putc ('\n', stderr
);
243 #endif /* not NO_VARARGS */
244 #endif /* not NO_STDARG */
249 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning,
250 * and locate warning in input file(s).
251 * Please us when there is no recovery, but we want to continue processing
252 * but not produce an object file.
253 * Please explain in string (which may have '\n's) what recovery was done.
257 void as_bad(const char *Format
, ...)
264 va_start(args
, Format
);
265 fprintf(stderr
,"Error: ");
267 vsprintf(buffer
, Format
, args
);
268 fputs (buffer
,stderr
);
270 listing_error(buffer
);
273 (void) putc('\n', stderr
);
277 void as_bad(Format
,va_alist
)
287 vsprintf(buffer
, Format
, args
);
288 fputs (buffer
, stderr
);
290 listing_error(buffer
);
294 (void) putc('\n', stderr
);
304 fprintf(stderr
,"Error: ");
305 _doprnt (Format
, &args
, stderr
);
306 (void)putc ('\n', stderr
);
309 #endif /* not NO_VARARGS */
310 #endif /* not NO_STDARG */
315 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
316 * message, and locate stdsource in input file(s).
317 * Please only use this for when we DON'T have some recovery action.
318 * It exit()s with a warning status.
322 void as_fatal(const char *Format
, ...)
327 va_start(args
, Format
);
328 fprintf (stderr
, "FATAL:");
329 vfprintf(stderr
, Format
, args
);
330 (void) putc('\n', stderr
);
336 void as_fatal(Format
,va_alist
)
344 fprintf (stderr
, "FATAL:");
345 vfprintf(stderr
, Format
, args
);
346 (void) putc('\n', stderr
);
352 as_fatal(Format
, args
)
356 fprintf(stderr
,"FATAL:");
357 _doprnt (Format
, &args
, stderr
);
358 (void)putc ('\n', stderr
);
360 exit(33); /* What is a good exit status? */
362 #endif /* not NO_VARARGS */
363 #endif /* not NO_STDARG */
365 /* end of messages.c */
This page took 0.036006 seconds and 4 git commands to generate.