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 1, 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. */
22 #include <stdio.h> /* define stderr */
32 #endif /* NO_VARARGS */
33 #endif /* NO_STDARG */
36 * Despite the rest of the comments in this file, (FIXME-SOON),
37 * here is the current scheme for error messages etc:
39 * as_fatal() is used when gas is quite confused and
40 * continuing the assembly is pointless. In this case we
41 * exit immediately with error status.
43 * as_bad() is used to mark errors that result in what we
44 * presume to be a useless object file. Say, we ignored
45 * something that might have been vital. If we see any of
46 * these, assembly will continue to the end of the source,
47 * no object file will be produced, and we will terminate
48 * with error status. The new option, -Z, tells us to
49 * produce an object file anyway but we still exit with
50 * error status. The assumption here is that you don't want
51 * this object file but we could be wrong.
53 * as_warn() is used when we have an error from which we
54 * have a plausible error recovery. eg, masking the top
55 * bits of a constant that is longer than will fit in the
56 * destination. In this case we will continue to assemble
57 * the source, although we may have made a bad assumption,
58 * and we will produce an object file and return normal exit
59 * status (ie, no error). The new option -X tells us to
60 * treat all as_warn() errors as as_bad() errors. That is,
61 * no object file will be produced and we will exit with
62 * error status. The idea here is that we don't kill an
63 * entire make because of an error that we knew how to
64 * correct. On the other hand, sometimes you might want to
65 * stop the make at these points.
67 * as_tsktsk() is used when we see a minor error for which
68 * our error recovery action is almost certainly correct.
69 * In this case, we print a message and then assembly
70 * continues as though no error occurred.
76 JF: this is now bogus. We now print more standard error messages
77 that try to look like everyone else's.
79 We print the error message 1st, beginning in column 1.
80 All ancillary info starts in column 2 on lines after the
82 We try to print a location in logical and physical file
83 just after the main error text.
84 Caller then prints any appendices after that, begining all
85 lines with at least 1 space.
87 Optionally, we may die.
88 There is no need for a trailing '\n' in your error text format
89 because we supply one.
91 as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
93 as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
97 static int warning_count
= 0; /* Count of number of warnings issued */
100 return(warning_count
);
103 /* Nonzero if we've hit a 'bad error', and should not write an obj file,
104 and exit with a nonzero error code */
106 static int error_count
= 0;
116 * Like perror(3), but with more info.
118 void as_perror(gripe
, filename
)
119 char *gripe
; /* Unpunctuated error theme. */
123 extern char *sys_errlist
[];
126 fprintf(stderr
,gripe
,filename
);
128 if (errno
> sys_nerr
)
129 fprintf(stderr
, "Unknown error #%d.\n", errno
);
131 fprintf(stderr
, "%s.\n", sys_errlist
[errno
]);
132 errno
= 0; /* After reporting, clear it. */
136 * a s _ t s k t s k ()
138 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
140 * Please only use this for when we have some recovery action.
141 * Please explain in string (which may have '\n's) what recovery was done.
145 void as_tsktsk(Format
)
151 va_start(args
, Format
);
152 vfprintf(stderr
, Format
, args
);
154 (void) putc('\n', stderr
);
158 void as_tsktsk(Format
,va_alist
)
166 vfprintf(stderr
, Format
, args
);
168 (void) putc('\n', stderr
);
172 as_tsktsk(Format
,args
)
176 _doprnt (Format
, &args
, stderr
);
177 (void)putc ('\n', stderr
);
180 #endif /* not NO_VARARGS */
181 #endif /* not NO_STDARG */
184 void as_tsktsk(Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
)
188 fprintf(stderr
,Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
);
189 (void)putc('\n',stderr
);
195 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
197 * Please only use this for when we have some recovery action.
198 * Please explain in string (which may have '\n's) what recovery was done.
210 va_start(args
, Format
);
211 vfprintf(stderr
, Format
, args
);
213 (void) putc('\n', stderr
);
218 void as_warn(Format
,va_alist
)
228 vfprintf(stderr
, Format
, args
);
230 (void) putc('\n', stderr
);
238 /* -W supresses warning messages. */
239 if (! flagseen
['W']) {
242 _doprnt (Format
, &args
, stderr
);
243 (void)putc ('\n', stderr
);
247 #endif /* not NO_VARARGS */
248 #endif /* not NO_STDARG */
251 void as_warn(Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
)
257 fprintf(stderr
,Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
);
258 (void)putc('\n',stderr
);
265 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning,
266 * and locate warning in input file(s).
267 * Please us when there is no recovery, but we want to continue processing
268 * but not produce an object file.
269 * Please explain in string (which may have '\n's) what recovery was done.
280 va_start(args
, Format
);
281 vfprintf(stderr
, Format
, args
);
283 (void) putc('\n', stderr
);
287 void as_bad(Format
,va_alist
)
296 vfprintf(stderr
, Format
, args
);
298 (void) putc('\n', stderr
);
307 _doprnt (Format
, &args
, stderr
);
308 (void)putc ('\n', stderr
);
311 #endif /* not NO_VARARGS */
312 #endif /* not NO_STDARG */
315 void as_bad(Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
)
320 fprintf(stderr
,Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
);
321 (void)putc('\n',stderr
);
328 * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
329 * message, and locate stdsource in input file(s).
330 * Please only use this for when we DON'T have some recovery action.
331 * It exit()s with a warning status.
335 void as_fatal(Format
)
341 va_start(args
, Format
);
342 fprintf (stderr
, "FATAL:");
343 vfprintf(stderr
, Format
, args
);
344 (void) putc('\n', stderr
);
350 void as_fatal(Format
,va_alist
)
358 fprintf (stderr
, "FATAL:");
359 vfprintf(stderr
, Format
, args
);
360 (void) putc('\n', stderr
);
366 as_fatal(Format
, args
)
370 fprintf(stderr
,"FATAL:");
371 _doprnt (Format
, &args
, stderr
);
372 (void)putc ('\n', stderr
);
374 exit(42); /* What is a good exit status? */
376 #endif /* not NO_VARARGS */
377 #endif /* not NO_STDARG */
380 void as_fatal(Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
)
384 fprintf (stderr
, "FATAL:");
385 fprintf(stderr
, Format
,aa
,ab
,ac
,ad
,ae
,af
,ag
,ah
,ai
,aj
,ak
,al
,am
,an
);
386 (void) putc('\n', stderr
);
391 /* end: messages.c */