* stack.c (print_frame_info): When checking PC_IN_CALL_DUMMY,
[deliverable/binutils-gdb.git] / gas / messages.c
CommitLineData
fecd2382 1/* messages.c - error reporter -
c1c28543 2 Copyright (C) 1987, 1991, 1992 Free Software Foundation, Inc.
6efd877d 3
fecd2382 4 This file is part of GAS, the GNU Assembler.
6efd877d 5
fecd2382
RP
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
a39116f1 8 the Free Software Foundation; either version 2, or (at your option)
fecd2382 9 any later version.
6efd877d 10
fecd2382
RP
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.
6efd877d 15
fecd2382
RP
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. */
19
6efd877d 20#include <stdio.h> /* define stderr */
fecd2382
RP
21#include <errno.h>
22
23#include "as.h"
24
4959cb7b
KR
25#ifndef __STDC__
26#ifndef NO_STDARG
27#define NO_STDARG
28#endif
29#endif
30
fecd2382
RP
31#ifndef NO_STDARG
32#include <stdarg.h>
33#else
34#ifndef NO_VARARGS
35#include <varargs.h>
36#endif /* NO_VARARGS */
37#endif /* NO_STDARG */
38
39/*
40 * Despite the rest of the comments in this file, (FIXME-SOON),
41 * here is the current scheme for error messages etc:
42 *
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.
46 *
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.
56 *
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.
70 *
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.
75 */
76
77/*
78 ERRORS
6efd877d 79
fecd2382
RP
80 JF: this is now bogus. We now print more standard error messages
81 that try to look like everyone else's.
6efd877d 82
fecd2382
RP
83 We print the error message 1st, beginning in column 1.
84 All ancillary info starts in column 2 on lines after the
85 key error text.
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.
6efd877d 90
fecd2382
RP
91 Optionally, we may die.
92 There is no need for a trailing '\n' in your error text format
93 because we supply one.
6efd877d 94
fecd2382 95 as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
6efd877d 96
fecd2382 97 as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
6efd877d 98
a39116f1 99 */
fecd2382 100
6efd877d 101static int warning_count; /* Count of number of warnings issued */
fecd2382 102
6efd877d
KR
103int
104had_warnings ()
105{
106 return (warning_count);
107} /* had_err() */
fecd2382
RP
108
109/* Nonzero if we've hit a 'bad error', and should not write an obj file,
110 and exit with a nonzero error code */
111
09952cd9 112static int error_count;
fecd2382 113
6efd877d
KR
114int
115had_errors ()
116{
117 return (error_count);
118} /* had_errors() */
fecd2382
RP
119
120
121/*
122 * a s _ p e r r o r
123 *
124 * Like perror(3), but with more info.
125 */
6efd877d
KR
126void
127as_perror (gripe, filename)
128 char *gripe; /* Unpunctuated error theme. */
129 char *filename;
fecd2382 130{
c1c28543 131#ifndef HAVE_STRERROR
6efd877d 132 extern char *strerror ();
c1c28543
KR
133#endif /* HAVE_STRERROR */
134
6efd877d
KR
135 as_where ();
136 fprintf (stderr, gripe, filename);
137 fprintf (stderr, ": %s\n", strerror (errno));
138 errno = 0; /* After reporting, clear it. */
139} /* as_perror() */
fecd2382
RP
140
141/*
142 * a s _ t s k t s k ()
143 *
6efd877d 144 * Send to stderr a string as a warning, and locate warning
fecd2382
RP
145 * in input file(s).
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.
148 */
149
150#ifndef NO_STDARG
6efd877d
KR
151void
152as_tsktsk (const char *Format,...)
fecd2382 153{
6efd877d
KR
154 va_list args;
155
156 as_where ();
157 va_start (args, Format);
158 vfprintf (stderr, Format, args);
159 va_end (args);
160 (void) putc ('\n', stderr);
161} /* as_tsktsk() */
162
fecd2382
RP
163#else
164#ifndef NO_VARARGS
6efd877d
KR
165void
166as_tsktsk (Format, va_alist)
167 char *Format;
168 va_dcl
fecd2382 169{
6efd877d
KR
170 va_list args;
171
172 as_where ();
173 va_start (args);
174 vfprintf (stderr, Format, args);
175 va_end (args);
176 (void) putc ('\n', stderr);
177} /* as_tsktsk() */
178
fecd2382
RP
179#else
180/*VARARGS1 */
6efd877d
KR
181as_tsktsk (Format, args)
182 char *Format;
fecd2382 183{
6efd877d
KR
184 as_where ();
185 _doprnt (Format, &args, stderr);
186 (void) putc ('\n', stderr);
187 /* as_where(); */
188} /* as_tsktsk */
189
fecd2382
RP
190#endif /* not NO_VARARGS */
191#endif /* not NO_STDARG */
192
fecd2382
RP
193/*
194 * a s _ w a r n ()
195 *
09952cd9 196 * Send to stderr a string as a warning, and locate warning
fecd2382
RP
197 * in input file(s).
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.
200 */
201
202#ifndef NO_STDARG
6efd877d
KR
203void
204as_warn (const char *Format,...)
fecd2382 205{
6efd877d
KR
206 va_list args;
207 char buffer[200];
208
209 if (!flagseen['W'])
210 {
211 ++warning_count;
212 as_where ();
213 va_start (args, Format);
214 fprintf (stderr, "Warning: ");
215 vsprintf (buffer, Format, args);
216 fputs (buffer, stderr);
a39116f1 217#ifndef NO_LISTING
6efd877d 218 listing_warning (buffer);
a39116f1 219#endif
6efd877d
KR
220 va_end (args);
221 (void) putc ('\n', stderr);
222 }
223} /* as_warn() */
224
fecd2382
RP
225#else
226#ifndef NO_VARARGS
6efd877d
KR
227void
228as_warn (Format, va_alist)
229 char *Format;
230 va_dcl
fecd2382 231{
6efd877d
KR
232 va_list args;
233 char buffer[200];
234
235 if (!flagseen['W'])
236 {
237 ++warning_count;
238 as_where ();
239 va_start (args);
240 fprintf (stderr, "Warning: ");
241 vsprintf (buffer, Format, args);
242 fputs (buffer, stderr);
a39116f1 243#ifndef NO_LISTING
6efd877d
KR
244 listing_warning (buffer);
245#endif
246 va_end (args);
247 (void) putc ('\n', stderr);
248 }
249} /* as_warn() */
250
fecd2382
RP
251#else
252/*VARARGS1 */
6efd877d
KR
253as_warn (Format, args)
254 char *Format;
fecd2382 255{
6efd877d
KR
256 /* -W supresses warning messages. */
257 if (!flagseen['W'])
258 {
259 ++warning_count;
260 as_where ();
261 _doprnt (Format, &args, stderr);
262 (void) putc ('\n', stderr);
263 /* as_where(); */
264 }
265} /* as_warn() */
266
fecd2382
RP
267#endif /* not NO_VARARGS */
268#endif /* not NO_STDARG */
269
fecd2382
RP
270/*
271 * a s _ b a d ()
272 *
6efd877d 273 * Send to stderr a string as a warning, and locate warning in input file(s).
fecd2382
RP
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.
277 */
278
279#ifndef NO_STDARG
6efd877d
KR
280void
281as_bad (const char *Format,...)
fecd2382 282{
6efd877d
KR
283 va_list args;
284 char buffer[200];
285
286 ++error_count;
287 as_where ();
288 va_start (args, Format);
289 fprintf (stderr, "Error: ");
290
291 vsprintf (buffer, Format, args);
292 fputs (buffer, stderr);
a39116f1 293#ifndef NO_LISTING
6efd877d 294 listing_error (buffer);
a39116f1 295#endif
6efd877d
KR
296 va_end (args);
297 (void) putc ('\n', stderr);
298} /* as_bad() */
299
fecd2382
RP
300#else
301#ifndef NO_VARARGS
6efd877d
KR
302void
303as_bad (Format, va_alist)
304 char *Format;
305 va_dcl
fecd2382 306{
6efd877d
KR
307 va_list args;
308 char buffer[200];
309
310 ++error_count;
311 as_where ();
312 va_start (args);
313 vsprintf (buffer, Format, args);
314 fputs (buffer, stderr);
a39116f1 315#ifndef NO_LISTING
6efd877d 316 listing_error (buffer);
a39116f1 317#endif
6efd877d
KR
318
319 va_end (args);
320 (void) putc ('\n', stderr);
a39116f1 321} /* as_bad() */
6efd877d 322
fecd2382
RP
323#else
324/*VARARGS1 */
6efd877d
KR
325as_bad (Format, args)
326 char *Format;
fecd2382 327{
6efd877d
KR
328 ++error_count;
329
330 as_where ();
331 fprintf (stderr, "Error: ");
332 _doprnt (Format, &args, stderr);
333 (void) putc ('\n', stderr);
334 /* as_where(); */
335} /* as_bad() */
336
fecd2382
RP
337#endif /* not NO_VARARGS */
338#endif /* not NO_STDARG */
339
fecd2382
RP
340/*
341 * a s _ f a t a l ()
342 *
6efd877d
KR
343 * Send to stderr a string as a fatal message, and print location of error in
344 * input file(s).
fecd2382
RP
345 * Please only use this for when we DON'T have some recovery action.
346 * It exit()s with a warning status.
347 */
348
349#ifndef NO_STDARG
6efd877d
KR
350void
351as_fatal (const char *Format,...)
fecd2382 352{
6efd877d
KR
353 va_list args;
354
355 as_where ();
356 va_start (args, Format);
357 fprintf (stderr, "FATAL:");
358 vfprintf (stderr, Format, args);
359 (void) putc ('\n', stderr);
360 va_end (args);
361 exit (33);
362} /* as_fatal() */
363
fecd2382
RP
364#else
365#ifndef NO_VARARGS
6efd877d
KR
366void
367as_fatal (Format, va_alist)
368 char *Format;
369 va_dcl
fecd2382 370{
6efd877d
KR
371 va_list args;
372
373 as_where ();
374 va_start (args);
375 fprintf (stderr, "FATAL:");
376 vfprintf (stderr, Format, args);
377 (void) putc ('\n', stderr);
378 va_end (args);
379 exit (33);
380} /* as_fatal() */
381
fecd2382
RP
382#else
383/*VARARGS1 */
6efd877d
KR
384as_fatal (Format, args)
385 char *Format;
fecd2382 386{
6efd877d
KR
387 as_where ();
388 fprintf (stderr, "FATAL:");
389 _doprnt (Format, &args, stderr);
390 (void) putc ('\n', stderr);
391 /* as_where(); */
392 exit (33); /* What is a good exit status? */
393} /* as_fatal() */
394
fecd2382
RP
395#endif /* not NO_VARARGS */
396#endif /* not NO_STDARG */
397
8b228fe9 398/* end of messages.c */
This page took 0.091828 seconds and 4 git commands to generate.