Rev 5222 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5222 | Rev 6324 | ||
---|---|---|---|
1 | /* messages.c - error reporter - |
1 | /* messages.c - error reporter - |
2 | Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001, |
- | |
3 | 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
- | |
4 | Free Software Foundation, Inc. |
2 | Copyright (C) 1987-2015 Free Software Foundation, Inc. |
5 | This file is part of GAS, the GNU Assembler. |
3 | This file is part of GAS, the GNU Assembler. |
6 | 4 | ||
7 | GAS is free software; you can redistribute it and/or modify |
5 | GAS is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 3, or (at your option) |
7 | the Free Software Foundation; either version 3, or (at your option) |
10 | any later version. |
8 | any later version. |
11 | 9 | ||
12 | GAS is distributed in the hope that it will be useful, |
10 | GAS is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
13 | GNU General Public License for more details. |
16 | 14 | ||
17 | You should have received a copy of the GNU General Public License |
15 | You should have received a copy of the GNU General Public License |
18 | along with GAS; see the file COPYING. If not, write to the Free |
16 | along with GAS; see the file COPYING. If not, write to the Free |
19 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
17 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
20 | 02110-1301, USA. */ |
18 | 02110-1301, USA. */ |
21 | 19 | ||
22 | #include "as.h" |
20 | #include "as.h" |
23 | 21 | ||
24 | static void identify (char *); |
22 | static void identify (char *); |
25 | static void as_show_where (void); |
23 | static void as_show_where (void); |
26 | static void as_warn_internal (char *, unsigned int, char *); |
24 | static void as_warn_internal (char *, unsigned int, char *); |
27 | static void as_bad_internal (char *, unsigned int, char *); |
25 | static void as_bad_internal (char *, unsigned int, char *); |
28 | 26 | ||
29 | /* Despite the rest of the comments in this file, (FIXME-SOON), |
27 | /* Despite the rest of the comments in this file, (FIXME-SOON), |
30 | here is the current scheme for error messages etc: |
28 | here is the current scheme for error messages etc: |
31 | 29 | ||
32 | as_fatal() is used when gas is quite confused and |
30 | as_fatal() is used when gas is quite confused and |
33 | continuing the assembly is pointless. In this case we |
31 | continuing the assembly is pointless. In this case we |
34 | exit immediately with error status. |
32 | exit immediately with error status. |
35 | 33 | ||
36 | as_bad() is used to mark errors that result in what we |
34 | as_bad() is used to mark errors that result in what we |
37 | presume to be a useless object file. Say, we ignored |
35 | presume to be a useless object file. Say, we ignored |
38 | something that might have been vital. If we see any of |
36 | something that might have been vital. If we see any of |
39 | these, assembly will continue to the end of the source, |
37 | these, assembly will continue to the end of the source, |
40 | no object file will be produced, and we will terminate |
38 | no object file will be produced, and we will terminate |
41 | with error status. The new option, -Z, tells us to |
39 | with error status. The new option, -Z, tells us to |
42 | produce an object file anyway but we still exit with |
40 | produce an object file anyway but we still exit with |
43 | error status. The assumption here is that you don't want |
41 | error status. The assumption here is that you don't want |
44 | this object file but we could be wrong. |
42 | this object file but we could be wrong. |
45 | 43 | ||
46 | as_warn() is used when we have an error from which we |
44 | as_warn() is used when we have an error from which we |
47 | have a plausible error recovery. eg, masking the top |
45 | have a plausible error recovery. eg, masking the top |
48 | bits of a constant that is longer than will fit in the |
46 | bits of a constant that is longer than will fit in the |
49 | destination. In this case we will continue to assemble |
47 | destination. In this case we will continue to assemble |
50 | the source, although we may have made a bad assumption, |
48 | the source, although we may have made a bad assumption, |
51 | and we will produce an object file and return normal exit |
49 | and we will produce an object file and return normal exit |
52 | status (ie, no error). The new option -X tells us to |
50 | status (ie, no error). The new option -X tells us to |
53 | treat all as_warn() errors as as_bad() errors. That is, |
51 | treat all as_warn() errors as as_bad() errors. That is, |
54 | no object file will be produced and we will exit with |
52 | no object file will be produced and we will exit with |
55 | error status. The idea here is that we don't kill an |
53 | error status. The idea here is that we don't kill an |
56 | entire make because of an error that we knew how to |
54 | entire make because of an error that we knew how to |
57 | correct. On the other hand, sometimes you might want to |
55 | correct. On the other hand, sometimes you might want to |
58 | stop the make at these points. |
56 | stop the make at these points. |
59 | 57 | ||
60 | as_tsktsk() is used when we see a minor error for which |
58 | as_tsktsk() is used when we see a minor error for which |
61 | our error recovery action is almost certainly correct. |
59 | our error recovery action is almost certainly correct. |
62 | In this case, we print a message and then assembly |
60 | In this case, we print a message and then assembly |
63 | continues as though no error occurred. */ |
61 | continues as though no error occurred. */ |
64 | 62 | ||
65 | static void |
63 | static void |
66 | identify (char *file) |
64 | identify (char *file) |
67 | { |
65 | { |
68 | static int identified; |
66 | static int identified; |
69 | 67 | ||
70 | if (identified) |
68 | if (identified) |
71 | return; |
69 | return; |
72 | identified++; |
70 | identified++; |
73 | 71 | ||
74 | if (!file) |
72 | if (!file) |
75 | { |
73 | { |
76 | unsigned int x; |
74 | unsigned int x; |
77 | as_where (&file, &x); |
75 | as_where (&file, &x); |
78 | } |
76 | } |
79 | 77 | ||
80 | if (file) |
78 | if (file) |
81 | fprintf (stderr, "%s: ", file); |
79 | fprintf (stderr, "%s: ", file); |
82 | fprintf (stderr, _("Assembler messages:\n")); |
80 | fprintf (stderr, _("Assembler messages:\n")); |
83 | } |
81 | } |
84 | 82 | ||
85 | /* The number of warnings issued. */ |
83 | /* The number of warnings issued. */ |
86 | static int warning_count; |
84 | static int warning_count; |
87 | 85 | ||
88 | int |
86 | int |
89 | had_warnings (void) |
87 | had_warnings (void) |
90 | { |
88 | { |
91 | return warning_count; |
89 | return warning_count; |
92 | } |
90 | } |
93 | 91 | ||
94 | /* Nonzero if we've hit a 'bad error', and should not write an obj file, |
92 | /* Nonzero if we've hit a 'bad error', and should not write an obj file, |
95 | and exit with a nonzero error code. */ |
93 | and exit with a nonzero error code. */ |
96 | 94 | ||
97 | static int error_count; |
95 | static int error_count; |
98 | 96 | ||
99 | int |
97 | int |
100 | had_errors (void) |
98 | had_errors (void) |
101 | { |
99 | { |
102 | return error_count; |
100 | return error_count; |
103 | } |
101 | } |
104 | 102 | ||
105 | /* Print the current location to stderr. */ |
103 | /* Print the current location to stderr. */ |
106 | 104 | ||
107 | static void |
105 | static void |
108 | as_show_where (void) |
106 | as_show_where (void) |
109 | { |
107 | { |
110 | char *file; |
108 | char *file; |
111 | unsigned int line; |
109 | unsigned int line; |
112 | 110 | ||
113 | as_where (&file, &line); |
111 | as_where (&file, &line); |
114 | identify (file); |
112 | identify (file); |
115 | if (file) |
113 | if (file) |
116 | { |
114 | { |
117 | if (line != 0) |
115 | if (line != 0) |
118 | fprintf (stderr, "%s:%u: ", file, line); |
116 | fprintf (stderr, "%s:%u: ", file, line); |
119 | else |
117 | else |
120 | fprintf (stderr, "%s: ", file); |
118 | fprintf (stderr, "%s: ", file); |
121 | } |
119 | } |
122 | } |
120 | } |
123 | 121 | ||
124 | /* Send to stderr a string as a warning, and locate warning |
122 | /* Send to stderr a string as a warning, and locate warning |
125 | in input file(s). |
123 | in input file(s). |
126 | Please only use this for when we have some recovery action. |
124 | Please only use this for when we have some recovery action. |
127 | Please explain in string (which may have '\n's) what recovery was |
125 | Please explain in string (which may have '\n's) what recovery was |
128 | done. */ |
126 | done. */ |
129 | 127 | ||
130 | void |
128 | void |
131 | as_tsktsk (const char *format, ...) |
129 | as_tsktsk (const char *format, ...) |
132 | { |
130 | { |
133 | va_list args; |
131 | va_list args; |
134 | 132 | ||
135 | as_show_where (); |
133 | as_show_where (); |
136 | va_start (args, format); |
134 | va_start (args, format); |
137 | vfprintf (stderr, format, args); |
135 | vfprintf (stderr, format, args); |
138 | va_end (args); |
136 | va_end (args); |
139 | (void) putc ('\n', stderr); |
137 | (void) putc ('\n', stderr); |
140 | } |
138 | } |
141 | 139 | ||
142 | /* The common portion of as_warn and as_warn_where. */ |
140 | /* The common portion of as_warn and as_warn_where. */ |
143 | 141 | ||
144 | static void |
142 | static void |
145 | as_warn_internal (char *file, unsigned int line, char *buffer) |
143 | as_warn_internal (char *file, unsigned int line, char *buffer) |
146 | { |
144 | { |
147 | ++warning_count; |
145 | ++warning_count; |
148 | 146 | ||
149 | if (file == NULL) |
147 | if (file == NULL) |
150 | as_where (&file, &line); |
148 | as_where (&file, &line); |
151 | 149 | ||
152 | identify (file); |
150 | identify (file); |
153 | if (file) |
151 | if (file) |
154 | { |
152 | { |
155 | if (line != 0) |
153 | if (line != 0) |
156 | fprintf (stderr, "%s:%u: ", file, line); |
154 | fprintf (stderr, "%s:%u: %s%s\n", file, line, _("Warning: "), buffer); |
157 | else |
155 | else |
158 | fprintf (stderr, "%s: ", file); |
156 | fprintf (stderr, "%s: %s%s\n", file, _("Warning: "), buffer); |
159 | } |
157 | } |
- | 158 | else |
|
160 | fprintf (stderr, _("Warning: ")); |
159 | fprintf (stderr, "%s%s\n", _("Warning: "), buffer); |
161 | fputs (buffer, stderr); |
- | |
162 | (void) putc ('\n', stderr); |
- | |
163 | #ifndef NO_LISTING |
160 | #ifndef NO_LISTING |
164 | listing_warning (buffer); |
161 | listing_warning (buffer); |
165 | #endif |
162 | #endif |
166 | } |
163 | } |
167 | 164 | ||
168 | /* Send to stderr a string as a warning, and locate warning |
165 | /* Send to stderr a string as a warning, and locate warning |
169 | in input file(s). |
166 | in input file(s). |
170 | Please only use this for when we have some recovery action. |
167 | Please only use this for when we have some recovery action. |
171 | Please explain in string (which may have '\n's) what recovery was |
168 | Please explain in string (which may have '\n's) what recovery was |
172 | done. */ |
169 | done. */ |
173 | 170 | ||
174 | void |
171 | void |
175 | as_warn (const char *format, ...) |
172 | as_warn (const char *format, ...) |
176 | { |
173 | { |
177 | va_list args; |
174 | va_list args; |
178 | char buffer[2000]; |
175 | char buffer[2000]; |
179 | 176 | ||
180 | if (!flag_no_warnings) |
177 | if (!flag_no_warnings) |
181 | { |
178 | { |
182 | va_start (args, format); |
179 | va_start (args, format); |
183 | vsnprintf (buffer, sizeof (buffer), format, args); |
180 | vsnprintf (buffer, sizeof (buffer), format, args); |
184 | va_end (args); |
181 | va_end (args); |
185 | as_warn_internal ((char *) NULL, 0, buffer); |
182 | as_warn_internal ((char *) NULL, 0, buffer); |
186 | } |
183 | } |
187 | } |
184 | } |
188 | 185 | ||
189 | /* Like as_bad but the file name and line number are passed in. |
186 | /* Like as_bad but the file name and line number are passed in. |
190 | Unfortunately, we have to repeat the function in order to handle |
187 | Unfortunately, we have to repeat the function in order to handle |
191 | the varargs correctly and portably. */ |
188 | the varargs correctly and portably. */ |
192 | 189 | ||
193 | void |
190 | void |
194 | as_warn_where (char *file, unsigned int line, const char *format, ...) |
191 | as_warn_where (char *file, unsigned int line, const char *format, ...) |
195 | { |
192 | { |
196 | va_list args; |
193 | va_list args; |
197 | char buffer[2000]; |
194 | char buffer[2000]; |
198 | 195 | ||
199 | if (!flag_no_warnings) |
196 | if (!flag_no_warnings) |
200 | { |
197 | { |
201 | va_start (args, format); |
198 | va_start (args, format); |
202 | vsnprintf (buffer, sizeof (buffer), format, args); |
199 | vsnprintf (buffer, sizeof (buffer), format, args); |
203 | va_end (args); |
200 | va_end (args); |
204 | as_warn_internal (file, line, buffer); |
201 | as_warn_internal (file, line, buffer); |
205 | } |
202 | } |
206 | } |
203 | } |
207 | 204 | ||
208 | /* The common portion of as_bad and as_bad_where. */ |
205 | /* The common portion of as_bad and as_bad_where. */ |
209 | 206 | ||
210 | static void |
207 | static void |
211 | as_bad_internal (char *file, unsigned int line, char *buffer) |
208 | as_bad_internal (char *file, unsigned int line, char *buffer) |
212 | { |
209 | { |
213 | ++error_count; |
210 | ++error_count; |
214 | 211 | ||
215 | if (file == NULL) |
212 | if (file == NULL) |
216 | as_where (&file, &line); |
213 | as_where (&file, &line); |
217 | 214 | ||
218 | identify (file); |
215 | identify (file); |
219 | if (file) |
216 | if (file) |
220 | { |
217 | { |
221 | if (line != 0) |
218 | if (line != 0) |
222 | fprintf (stderr, "%s:%u: ", file, line); |
219 | fprintf (stderr, "%s:%u: %s%s\n", file, line, _("Error: "), buffer); |
223 | else |
220 | else |
224 | fprintf (stderr, "%s: ", file); |
221 | fprintf (stderr, "%s: %s%s\n", file, _("Error: "), buffer); |
225 | } |
222 | } |
- | 223 | else |
|
226 | fprintf (stderr, _("Error: ")); |
224 | fprintf (stderr, "%s%s\n", _("Error: "), buffer); |
227 | fputs (buffer, stderr); |
- | |
228 | (void) putc ('\n', stderr); |
- | |
229 | #ifndef NO_LISTING |
225 | #ifndef NO_LISTING |
230 | listing_error (buffer); |
226 | listing_error (buffer); |
231 | #endif |
227 | #endif |
232 | } |
228 | } |
233 | 229 | ||
234 | /* Send to stderr a string as a warning, and locate warning in input |
230 | /* Send to stderr a string as a warning, and locate warning in input |
235 | file(s). Please us when there is no recovery, but we want to |
231 | file(s). Please us when there is no recovery, but we want to |
236 | continue processing but not produce an object file. |
232 | continue processing but not produce an object file. |
237 | Please explain in string (which may have '\n's) what recovery was |
233 | Please explain in string (which may have '\n's) what recovery was |
238 | done. */ |
234 | done. */ |
239 | 235 | ||
240 | void |
236 | void |
241 | as_bad (const char *format, ...) |
237 | as_bad (const char *format, ...) |
242 | { |
238 | { |
243 | va_list args; |
239 | va_list args; |
244 | char buffer[2000]; |
240 | char buffer[2000]; |
245 | 241 | ||
246 | va_start (args, format); |
242 | va_start (args, format); |
247 | vsnprintf (buffer, sizeof (buffer), format, args); |
243 | vsnprintf (buffer, sizeof (buffer), format, args); |
248 | va_end (args); |
244 | va_end (args); |
249 | 245 | ||
250 | as_bad_internal ((char *) NULL, 0, buffer); |
246 | as_bad_internal ((char *) NULL, 0, buffer); |
251 | } |
247 | } |
252 | 248 | ||
253 | /* Like as_bad but the file name and line number are passed in. |
249 | /* Like as_bad but the file name and line number are passed in. |
254 | Unfortunately, we have to repeat the function in order to handle |
250 | Unfortunately, we have to repeat the function in order to handle |
255 | the varargs correctly and portably. */ |
251 | the varargs correctly and portably. */ |
256 | 252 | ||
257 | void |
253 | void |
258 | as_bad_where (char *file, unsigned int line, const char *format, ...) |
254 | as_bad_where (char *file, unsigned int line, const char *format, ...) |
259 | { |
255 | { |
260 | va_list args; |
256 | va_list args; |
261 | char buffer[2000]; |
257 | char buffer[2000]; |
262 | 258 | ||
263 | va_start (args, format); |
259 | va_start (args, format); |
264 | vsnprintf (buffer, sizeof (buffer), format, args); |
260 | vsnprintf (buffer, sizeof (buffer), format, args); |
265 | va_end (args); |
261 | va_end (args); |
266 | 262 | ||
267 | as_bad_internal (file, line, buffer); |
263 | as_bad_internal (file, line, buffer); |
268 | } |
264 | } |
269 | 265 | ||
270 | /* Send to stderr a string as a fatal message, and print location of |
266 | /* Send to stderr a string as a fatal message, and print location of |
271 | error in input file(s). |
267 | error in input file(s). |
272 | Please only use this for when we DON'T have some recovery action. |
268 | Please only use this for when we DON'T have some recovery action. |
273 | It xexit()s with a warning status. */ |
269 | It xexit()s with a warning status. */ |
274 | 270 | ||
275 | void |
271 | void |
276 | as_fatal (const char *format, ...) |
272 | as_fatal (const char *format, ...) |
277 | { |
273 | { |
278 | va_list args; |
274 | va_list args; |
279 | 275 | ||
280 | as_show_where (); |
276 | as_show_where (); |
281 | va_start (args, format); |
277 | va_start (args, format); |
282 | fprintf (stderr, _("Fatal error: ")); |
278 | fprintf (stderr, _("Fatal error: ")); |
283 | vfprintf (stderr, format, args); |
279 | vfprintf (stderr, format, args); |
284 | (void) putc ('\n', stderr); |
280 | (void) putc ('\n', stderr); |
285 | va_end (args); |
281 | va_end (args); |
286 | /* Delete the output file, if it exists. This will prevent make from |
282 | /* Delete the output file, if it exists. This will prevent make from |
287 | thinking that a file was created and hence does not need rebuilding. */ |
283 | thinking that a file was created and hence does not need rebuilding. */ |
288 | if (out_file_name != NULL) |
284 | if (out_file_name != NULL) |
289 | unlink_if_ordinary (out_file_name); |
285 | unlink_if_ordinary (out_file_name); |
290 | xexit (EXIT_FAILURE); |
286 | xexit (EXIT_FAILURE); |
291 | } |
287 | } |
292 | 288 | ||
293 | /* Indicate assertion failure. |
289 | /* Indicate assertion failure. |
294 | Arguments: Filename, line number, optional function name. */ |
290 | Arguments: Filename, line number, optional function name. */ |
295 | 291 | ||
296 | void |
292 | void |
297 | as_assert (const char *file, int line, const char *fn) |
293 | as_assert (const char *file, int line, const char *fn) |
298 | { |
294 | { |
299 | as_show_where (); |
295 | as_show_where (); |
300 | fprintf (stderr, _("Internal error!\n")); |
296 | fprintf (stderr, _("Internal error!\n")); |
301 | if (fn) |
297 | if (fn) |
302 | fprintf (stderr, _("Assertion failure in %s at %s line %d.\n"), |
298 | fprintf (stderr, _("Assertion failure in %s at %s:%d.\n"), |
303 | fn, file, line); |
299 | fn, file, line); |
304 | else |
300 | else |
305 | fprintf (stderr, _("Assertion failure at %s line %d.\n"), file, line); |
301 | fprintf (stderr, _("Assertion failure at %s:%d.\n"), file, line); |
306 | fprintf (stderr, _("Please report this bug.\n")); |
302 | fprintf (stderr, _("Please report this bug.\n")); |
307 | xexit (EXIT_FAILURE); |
303 | xexit (EXIT_FAILURE); |
308 | } |
304 | } |
309 | 305 | ||
310 | /* as_abort: Print a friendly message saying how totally hosed we are, |
306 | /* as_abort: Print a friendly message saying how totally hosed we are, |
311 | and exit without producing a core file. */ |
307 | and exit without producing a core file. */ |
312 | 308 | ||
313 | void |
309 | void |
314 | as_abort (const char *file, int line, const char *fn) |
310 | as_abort (const char *file, int line, const char *fn) |
315 | { |
311 | { |
316 | as_show_where (); |
312 | as_show_where (); |
317 | if (fn) |
313 | if (fn) |
318 | fprintf (stderr, _("Internal error, aborting at %s line %d in %s\n"), |
314 | fprintf (stderr, _("Internal error, aborting at %s:%d in %s\n"), |
319 | file, line, fn); |
315 | file, line, fn); |
320 | else |
316 | else |
321 | fprintf (stderr, _("Internal error, aborting at %s line %d\n"), |
317 | fprintf (stderr, _("Internal error, aborting at %s:%d\n"), |
322 | file, line); |
318 | file, line); |
323 | fprintf (stderr, _("Please report this bug.\n")); |
319 | fprintf (stderr, _("Please report this bug.\n")); |
324 | xexit (EXIT_FAILURE); |
320 | xexit (EXIT_FAILURE); |
325 | } |
321 | } |
326 | 322 | ||
327 | /* Support routines. */ |
323 | /* Support routines. */ |
328 | 324 | ||
329 | void |
325 | void |
330 | sprint_value (char *buf, valueT val) |
326 | sprint_value (char *buf, valueT val) |
331 | { |
327 | { |
332 | if (sizeof (val) <= sizeof (long)) |
328 | if (sizeof (val) <= sizeof (long)) |
333 | { |
329 | { |
334 | sprintf (buf, "%ld", (long) val); |
330 | sprintf (buf, "%ld", (long) val); |
335 | return; |
331 | return; |
336 | } |
332 | } |
337 | if (sizeof (val) <= sizeof (bfd_vma)) |
333 | if (sizeof (val) <= sizeof (bfd_vma)) |
338 | { |
334 | { |
339 | sprintf_vma (buf, val); |
335 | sprintf_vma (buf, val); |
340 | return; |
336 | return; |
341 | } |
337 | } |
342 | abort (); |
338 | abort (); |
343 | } |
339 | } |
344 | 340 | ||
345 | #define HEX_MAX_THRESHOLD 1024 |
341 | #define HEX_MAX_THRESHOLD 1024 |
346 | #define HEX_MIN_THRESHOLD -(HEX_MAX_THRESHOLD) |
342 | #define HEX_MIN_THRESHOLD -(HEX_MAX_THRESHOLD) |
347 | 343 | ||
348 | static void |
344 | static void |
349 | as_internal_value_out_of_range (char * prefix, |
345 | as_internal_value_out_of_range (char * prefix, |
350 | offsetT val, |
346 | offsetT val, |
351 | offsetT min, |
347 | offsetT min, |
352 | offsetT max, |
348 | offsetT max, |
353 | char * file, |
349 | char * file, |
354 | unsigned line, |
350 | unsigned line, |
355 | int bad) |
351 | int bad) |
356 | { |
352 | { |
357 | const char * err; |
353 | const char * err; |
358 | 354 | ||
359 | if (prefix == NULL) |
355 | if (prefix == NULL) |
360 | prefix = ""; |
356 | prefix = ""; |
361 | 357 | ||
362 | if (val >= min && val <= max) |
358 | if (val >= min && val <= max) |
363 | { |
359 | { |
364 | addressT right = max & -max; |
360 | addressT right = max & -max; |
365 | 361 | ||
366 | if (max <= 1) |
362 | if (max <= 1) |
367 | abort (); |
363 | abort (); |
368 | 364 | ||
369 | /* xgettext:c-format */ |
365 | /* xgettext:c-format */ |
370 | err = _("%s out of domain (%d is not a multiple of %d)"); |
366 | err = _("%s out of domain (%d is not a multiple of %d)"); |
371 | if (bad) |
367 | if (bad) |
372 | as_bad_where (file, line, err, |
368 | as_bad_where (file, line, err, |
373 | prefix, (int) val, (int) right); |
369 | prefix, (int) val, (int) right); |
374 | else |
370 | else |
375 | as_warn_where (file, line, err, |
371 | as_warn_where (file, line, err, |
376 | prefix, (int) val, (int) right); |
372 | prefix, (int) val, (int) right); |
377 | return; |
373 | return; |
378 | } |
374 | } |
379 | 375 | ||
380 | if ( val < HEX_MAX_THRESHOLD |
376 | if ( val < HEX_MAX_THRESHOLD |
381 | && min < HEX_MAX_THRESHOLD |
377 | && min < HEX_MAX_THRESHOLD |
382 | && max < HEX_MAX_THRESHOLD |
378 | && max < HEX_MAX_THRESHOLD |
383 | && val > HEX_MIN_THRESHOLD |
379 | && val > HEX_MIN_THRESHOLD |
384 | && min > HEX_MIN_THRESHOLD |
380 | && min > HEX_MIN_THRESHOLD |
385 | && max > HEX_MIN_THRESHOLD) |
381 | && max > HEX_MIN_THRESHOLD) |
386 | { |
382 | { |
387 | /* xgettext:c-format */ |
383 | /* xgettext:c-format */ |
388 | err = _("%s out of range (%d is not between %d and %d)"); |
384 | err = _("%s out of range (%d is not between %d and %d)"); |
389 | 385 | ||
390 | if (bad) |
386 | if (bad) |
391 | as_bad_where (file, line, err, |
387 | as_bad_where (file, line, err, |
392 | prefix, (int) val, (int) min, (int) max); |
388 | prefix, (int) val, (int) min, (int) max); |
393 | else |
389 | else |
394 | as_warn_where (file, line, err, |
390 | as_warn_where (file, line, err, |
395 | prefix, (int) val, (int) min, (int) max); |
391 | prefix, (int) val, (int) min, (int) max); |
396 | } |
392 | } |
397 | else |
393 | else |
398 | { |
394 | { |
399 | char val_buf [sizeof (val) * 3 + 2]; |
395 | char val_buf [sizeof (val) * 3 + 2]; |
400 | char min_buf [sizeof (val) * 3 + 2]; |
396 | char min_buf [sizeof (val) * 3 + 2]; |
401 | char max_buf [sizeof (val) * 3 + 2]; |
397 | char max_buf [sizeof (val) * 3 + 2]; |
402 | 398 | ||
403 | if (sizeof (val) > sizeof (bfd_vma)) |
399 | if (sizeof (val) > sizeof (bfd_vma)) |
404 | abort (); |
400 | abort (); |
405 | 401 | ||
406 | sprintf_vma (val_buf, (bfd_vma) val); |
402 | sprintf_vma (val_buf, (bfd_vma) val); |
407 | sprintf_vma (min_buf, (bfd_vma) min); |
403 | sprintf_vma (min_buf, (bfd_vma) min); |
408 | sprintf_vma (max_buf, (bfd_vma) max); |
404 | sprintf_vma (max_buf, (bfd_vma) max); |
409 | 405 | ||
410 | /* xgettext:c-format. */ |
406 | /* xgettext:c-format. */ |
411 | err = _("%s out of range (0x%s is not between 0x%s and 0x%s)"); |
407 | err = _("%s out of range (0x%s is not between 0x%s and 0x%s)"); |
412 | 408 | ||
413 | if (bad) |
409 | if (bad) |
414 | as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf); |
410 | as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf); |
415 | else |
411 | else |
416 | as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf); |
412 | as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf); |
417 | } |
413 | } |
418 | } |
414 | } |
419 | 415 | ||
420 | void |
416 | void |
421 | as_warn_value_out_of_range (char * prefix, |
417 | as_warn_value_out_of_range (char * prefix, |
422 | offsetT value, |
418 | offsetT value, |
423 | offsetT min, |
419 | offsetT min, |
424 | offsetT max, |
420 | offsetT max, |
425 | char * file, |
421 | char * file, |
426 | unsigned line) |
422 | unsigned line) |
427 | { |
423 | { |
428 | as_internal_value_out_of_range (prefix, value, min, max, file, line, 0); |
424 | as_internal_value_out_of_range (prefix, value, min, max, file, line, 0); |
429 | } |
425 | } |
430 | 426 | ||
431 | void |
427 | void |
432 | as_bad_value_out_of_range (char * prefix, |
428 | as_bad_value_out_of_range (char * prefix, |
433 | offsetT value, |
429 | offsetT value, |
434 | offsetT min, |
430 | offsetT min, |
435 | offsetT max, |
431 | offsetT max, |
436 | char * file, |
432 | char * file, |
437 | unsigned line) |
433 | unsigned line) |
438 | { |
434 | { |
439 | as_internal_value_out_of_range (prefix, value, min, max, file, line, 1); |
435 | as_internal_value_out_of_range (prefix, value, min, max, file, line, 1); |
440 | }>>>=>=>=>=> |
436 | }>>>=>=>=>=> |