1 /* messages.c - error reporter -
2 Copyright (C) 1987, 1991 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 = 0; /* 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 = 0;
114 * Like perror(3), but with more info.
116 void as_perror(gripe, filename)
117 char *gripe; /* Unpunctuated error theme. */
121 extern char *sys_errlist[];
124 fprintf(stderr,gripe,filename);
126 if (errno > sys_nerr)
127 fprintf(stderr, "Unknown error #%d.\n", errno);
129 fprintf(stderr, "%s.\n", sys_errlist[errno]);
130 errno = 0; /* After reporting, clear it. */
134 * a s _ t s k t s k ()
136 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
138 * Please only use this for when we have some recovery action.
139 * Please explain in string (which may have '\n's) what recovery was done.
143 void as_tsktsk(Format)
149 va_start(args, Format);
150 vfprintf(stderr, Format, args);
152 (void) putc('\n', stderr);
156 void as_tsktsk(Format,va_alist)
164 vfprintf(stderr, Format, args);
166 (void) putc('\n', stderr);
170 as_tsktsk(Format,args)
174 _doprnt (Format, &args, stderr);
175 (void)putc ('\n', stderr);
178 #endif /* not NO_VARARGS */
179 #endif /* not NO_STDARG */
182 void as_tsktsk(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
186 fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
187 (void)putc('\n',stderr);
193 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
195 * Please only use this for when we have some recovery action.
196 * Please explain in string (which may have '\n's) what recovery was done.
209 va_start(args, Format);
210 fprintf(stderr,"Warning: ");
211 vsprintf(buffer, Format, args);
212 fprintf(stderr, buffer);
214 listing_warning(buffer);
217 (void) putc('\n', stderr);
222 void as_warn(Format,va_alist)
233 fprintf(stderr,"Warning: ");
234 vsprintf(buffer, Format, args);
235 fprintf(stderr,buffer);
237 listing_warning(buffer);
240 (void) putc('\n', stderr);
248 /* -W supresses warning messages. */
249 if (! flagseen ['W']) {
252 _doprnt (Format, &args, stderr);
253 (void)putc ('\n', stderr);
257 #endif /* not NO_VARARGS */
258 #endif /* not NO_STDARG */
261 void as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
267 fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
268 (void)putc('\n',stderr);
275 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning,
276 * and locate warning in input file(s).
277 * Please us when there is no recovery, but we want to continue processing
278 * but not produce an object file.
279 * Please explain in string (which may have '\n's) what recovery was done.
291 va_start(args, Format);
292 fprintf(stderr,"Error: ");
294 vsprintf(buffer, Format, args);
295 fprintf(stderr,buffer);
297 listing_error(buffer);
300 (void) putc('\n', stderr);
304 void as_bad(Format,va_alist)
314 vsprintf(buffer, Format, args);
315 fprintf(stderr,buffer);
317 listing_error(buffer);
321 (void) putc('\n', stderr);
331 fprintf(stderr,"Error: ");
332 _doprnt (Format, &args, stderr);
333 (void)putc ('\n', stderr);
336 #endif /* not NO_VARARGS */
337 #endif /* not NO_STDARG */
340 void as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
345 fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
346 (void)putc('\n',stderr);
353 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
354 * message, and locate stdsource in input file(s).
355 * Please only use this for when we DON'T have some recovery action.
356 * It exit()s with a warning status.
360 void as_fatal(Format)
366 va_start(args, Format);
367 fprintf (stderr, "FATAL:");
368 vfprintf(stderr, Format, args);
369 (void) putc('\n', stderr);
375 void as_fatal(Format,va_alist)
383 fprintf (stderr, "FATAL:");
384 vfprintf(stderr, Format, args);
385 (void) putc('\n', stderr);
391 as_fatal(Format, args)
395 fprintf(stderr,"FATAL:");
396 _doprnt (Format, &args, stderr);
397 (void)putc ('\n', stderr);
399 exit(33); /* What is a good exit status? */
401 #endif /* not NO_VARARGS */
402 #endif /* not NO_STDARG */
405 void as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
409 fprintf (stderr, "FATAL:");
410 fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
411 (void) putc('\n', stderr);
416 /* end of messages.c */