1 /* Language-independent diagnostic subroutines for the GNU C compiler
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC 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 GNU CC 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 GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* This file implements the language independant aspect of diagnostic
26 #undef FLOAT /* This is for hpux. They should change hpux. */
27 #undef FFS /* Some systems define this in param.h. */
35 #include "insn-attr.h"
36 #include "insn-codes.h"
37 #include "insn-config.h"
40 #include "diagnostic.h"
42 #define obstack_chunk_alloc xmalloc
43 #define obstack_chunk_free free
46 static int doing_line_wrapping PARAMS ((void));
48 static char *vbuild_message_string PARAMS ((const char *, va_list));
49 static char *build_message_string PARAMS ((const char *, ...))
51 static char *build_location_prefix PARAMS ((const char *, int, int));
52 static void output_notice PARAMS ((output_buffer *, const char *));
53 static void line_wrapper_printf PARAMS ((FILE *, const char *, ...))
55 static void vline_wrapper_message_with_location PARAMS ((const char *, int,
58 static void notice PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1;
59 static void v_message_with_file_and_line PARAMS ((const char *, int, int,
60 const char *, va_list));
61 static void v_message_with_decl PARAMS ((tree, int, const char *, va_list));
62 static void file_and_line_for_asm PARAMS ((rtx, const char **, int *));
63 static void v_error_with_file_and_line PARAMS ((const char *, int,
64 const char *, va_list));
65 static void v_error_with_decl PARAMS ((tree, const char *, va_list));
66 static void v_error_for_asm PARAMS ((rtx, const char *, va_list));
67 static void vfatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
68 static void v_warning_with_file_and_line PARAMS ((const char *, int,
69 const char *, va_list));
70 static void v_warning_with_decl PARAMS ((tree, const char *, va_list));
71 static void v_warning_for_asm PARAMS ((rtx, const char *, va_list));
72 static void v_pedwarn_with_decl PARAMS ((tree, const char *, va_list));
73 static void v_pedwarn_with_file_and_line PARAMS ((const char *, int,
74 const char *, va_list));
75 static void vsorry PARAMS ((const char *, va_list));
76 static void report_file_and_line PARAMS ((const char *, int, int));
77 static void vnotice PARAMS ((FILE *, const char *, va_list));
78 static void set_real_maximum_length PARAMS ((output_buffer *));
80 extern int rtl_dump_and_exit;
81 extern int inhibit_warnings;
82 extern int warnings_are_errors;
83 extern int warningcount;
84 extern int errorcount;
86 /* Front-end specific tree formatter, if non-NULL. */
87 printer_fn lang_printer = NULL;
89 /* An output_buffer surrogate for stderr. */
90 static output_buffer global_output_buffer;
91 output_buffer *diagnostic_buffer = &global_output_buffer;
93 static int need_error_newline;
95 /* Function of last error message;
96 more generally, function such that if next error message is in it
97 then we don't have to mention the function name. */
98 static tree last_error_function = NULL;
100 /* Used to detect when input_file_stack has changed since last described. */
101 static int last_error_tick;
103 /* Called by report_error_function to print out function name.
104 * Default may be overridden by language front-ends. */
106 void (*print_error_function) PARAMS ((const char *)) =
107 default_print_error_function;
109 /* Maximum characters per line in automatic line wrapping mode.
110 Zero means don't wrap lines. */
112 int diagnostic_message_length_per_line;
114 /* Used to control every diagnostic message formatting. Front-ends should
115 call set_message_prefixing_rule to set up their politics. */
116 static int current_prefixing_rule;
118 /* Initialize the diagnostic message outputting machinery. */
121 initialize_diagnostics ()
123 /* By default, we don't line-wrap messages. */
124 diagnostic_message_length_per_line = 0;
125 set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE);
126 /* Proceed to actual initialization. */
127 default_initialize_buffer (diagnostic_buffer);
130 /* Predicate. Return 1 if we're in automatic line wrapping mode. */
133 doing_line_wrapping ()
135 return diagnostic_message_length_per_line > 0;
139 set_message_prefixing_rule (rule)
142 current_prefixing_rule = rule;
145 /* Returns true if BUFFER is in line-wrappind mode. */
147 output_is_line_wrapping (buffer)
148 output_buffer *buffer;
150 return buffer->ideal_maximum_length > 0;
153 /* Return BUFFER's prefix. */
155 output_get_prefix (buffer)
156 const output_buffer *buffer;
158 return buffer->prefix;
161 /* Subroutine of output_set_maximum_length. Set up BUFFER's
162 internal maximum characters per line. */
164 set_real_maximum_length (buffer)
165 output_buffer *buffer;
167 /* If we're told not to wrap lines then do the obvious thing. */
168 if (! output_is_line_wrapping (buffer))
169 buffer->maximum_length = buffer->ideal_maximum_length;
172 int prefix_length = buffer->prefix ? strlen (buffer->prefix) : 0;
173 /* If the prefix is ridiculously too long, output at least
175 if (buffer->ideal_maximum_length - prefix_length < 32)
176 buffer->maximum_length = buffer->ideal_maximum_length + 32;
178 buffer->maximum_length = buffer->ideal_maximum_length;
182 /* Sets the number of maximum characters per line BUFFER can output
183 in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
185 output_set_maximum_length (buffer, length)
186 output_buffer *buffer;
189 buffer->ideal_maximum_length = length;
190 set_real_maximum_length (buffer);
193 /* Sets BUFFER's PREFIX. */
195 output_set_prefix (buffer, prefix)
196 output_buffer *buffer;
199 buffer->prefix = prefix;
200 set_real_maximum_length (buffer);
201 buffer->emitted_prefix_p = 0;
204 /* Free BUFFER's prefix, a previously malloc()'d string. */
207 output_destroy_prefix (buffer)
208 output_buffer *buffer;
212 free ((char *) buffer->prefix);
213 buffer->prefix = NULL;
217 /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
218 characters per line. */
220 init_output_buffer (buffer, prefix, maximum_length)
221 output_buffer *buffer;
225 obstack_init (&buffer->obstack);
226 buffer->ideal_maximum_length = maximum_length;
227 buffer->line_length = 0;
228 output_set_prefix (buffer, prefix);
229 buffer->emitted_prefix_p = 0;
230 buffer->prefixing_rule = current_prefixing_rule;
232 buffer->cursor = NULL;
235 /* Initialize BUFFER with a NULL prefix and current diagnostic message
238 default_initialize_buffer (buffer)
239 output_buffer *buffer;
241 init_output_buffer (buffer, NULL, diagnostic_message_length_per_line);
244 /* Recompute diagnostic_buffer's attributes to reflect any change
245 in diagnostic formatting global options. */
247 reshape_diagnostic_buffer ()
249 diagnostic_buffer->ideal_maximum_length = diagnostic_message_length_per_line;
250 diagnostic_buffer->prefixing_rule = current_prefixing_rule;
251 set_real_maximum_length (diagnostic_buffer);
254 /* Reinitialize BUFFER. */
256 output_clear (buffer)
257 output_buffer *buffer;
259 obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
260 buffer->line_length = 0;
261 buffer->cursor = NULL;
262 buffer->emitted_prefix_p = 0;
265 /* Finishes to construct a NULL-terminated character string representing
266 the BUFFERed message. */
268 output_finish (buffer)
269 output_buffer *buffer;
271 obstack_1grow (&buffer->obstack, '\0');
272 return (const char *) obstack_finish (&buffer->obstack);
275 /* Return the amount of characters BUFFER can accept to
278 output_space_left (buffer)
279 const output_buffer *buffer;
281 return buffer->maximum_length - buffer->line_length;
284 /* Write out BUFFER's prefix. */
286 output_emit_prefix (buffer)
287 output_buffer *buffer;
291 switch (buffer->prefixing_rule)
294 case DIAGNOSTICS_SHOW_PREFIX_NEVER:
297 case DIAGNOSTICS_SHOW_PREFIX_ONCE:
298 if (buffer->emitted_prefix_p)
301 buffer->emitted_prefix_p = 1;
304 case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
305 buffer->line_length += strlen (buffer->prefix);
307 (&buffer->obstack, buffer->prefix, buffer->line_length);
313 /* Have BUFFER start a new line. */
315 output_add_newline (buffer)
316 output_buffer *buffer;
318 obstack_1grow (&buffer->obstack, '\n');
319 buffer->line_length = 0;
322 /* Appends a character to BUFFER. */
324 output_add_character (buffer, c)
325 output_buffer *buffer;
328 if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
329 output_add_newline (buffer);
330 obstack_1grow (&buffer->obstack, c);
331 ++buffer->line_length;
334 /* Adds a space to BUFFER. */
336 output_add_space (buffer)
337 output_buffer *buffer;
339 if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
341 output_add_newline (buffer);
344 obstack_1grow (&buffer->obstack, ' ');
345 ++buffer->line_length;
348 /* Add the stringified version of an integer to BUFFER. */
350 output_add_integer (buffer, i)
351 output_buffer *buffer;
354 /* This must be large enough to hold any printed integer or
355 floating-point value. */
356 static char digit_buffer[128];
358 sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, i);
359 output_add_string (buffer, digit_buffer);
362 /* Append a string deliminated by START and END to BUFFER. No wrapping is
363 done. The caller must ensure that it is safe to do so. */
366 output_append (buffer, start, end)
367 output_buffer *buffer;
373 /* Emit prefix and skip whitespace if we're starting a new line. */
374 if (buffer->line_length == 0)
376 output_emit_prefix (buffer);
377 while (start != end && *start == ' ')
381 obstack_grow (&buffer->obstack, start, n);
382 buffer->line_length += n;
385 /* Wrap a STRing into BUFFER. */
388 output_add_string (buffer, str)
389 output_buffer *buffer;
394 if (!output_is_line_wrapping (buffer))
395 output_append (buffer, str, str + strlen (str));
398 while (*p && *p != ' ' && *p != '\n')
401 if (p - str < output_space_left (buffer))
402 output_append (buffer, str, p);
405 output_add_newline (buffer);
406 output_append (buffer, str, p);
409 while (*p && *p == '\n')
411 output_add_newline (buffer);
419 /* Flush the content of BUFFER onto FILE and reinitialize BUFFER. */
422 output_flush_on (buffer, file)
423 output_buffer *buffer;
426 const char *text = output_finish (buffer);
428 output_clear (buffer);
431 /* Format MESSAGE into BUFFER. */
433 output_format (buffer, msg)
434 output_buffer *buffer;
437 for (buffer->cursor = msg; *buffer->cursor; ++buffer->cursor)
440 if (*buffer->cursor != '%')
442 output_add_character (buffer, *buffer->cursor);
446 /* We got a '%'. Let's see what happens. */
449 /* Let's handle the traditional cases. */
450 if (*buffer->cursor == 's')
451 output_add_string (buffer, va_arg (buffer->format_args, const char *));
452 else if (*buffer->cursor == 'd')
453 output_add_integer (buffer, va_arg (buffer->format_args, int));
454 else if (*buffer->cursor == '%')
455 /* It was a '%%'. Just output a '%'. */
456 output_add_character (buffer, '%');
457 else if (lang_printer)
458 (*lang_printer) (buffer);
461 /* Hmmm. The front-end failed to install a format translator
462 but called us with an unrecognized format. Sorry. */
466 output_finish (buffer);
470 vbuild_message_string (msgid, ap)
476 vasprintf (&str, msgid, ap);
480 /* Return a malloc'd string containing MSGID formatted a la
481 printf. The caller is reponsible for freeing the memory. */
484 build_message_string VPARAMS ((const char *msgid, ...))
486 #ifndef ANSI_PROTOTYPES
492 VA_START (ap, msgid);
494 #ifndef ANSI_PROTOTYPES
495 msgid = va_arg (ap, const char *);
498 str = vbuild_message_string (msgid, ap);
506 /* Return a malloc'd string describing a location. The caller is
507 responsible for freeing the memory. */
510 build_location_prefix (file, line, warn)
518 return build_message_string ("%s:%d: warning: ", file, line);
520 return build_message_string ("%s:%d: ", file, line);
525 return build_message_string ("%s: warning: ", progname);
527 return build_message_string ("%s: ", progname);
531 /* Format a MESSAGE into BUFFER. Automatically wrap lines. */
534 output_notice (buffer, msgid)
535 output_buffer *buffer;
538 char *message = vbuild_message_string (msgid, buffer->format_args);
540 output_add_string (buffer, message);
545 /* Format a message into BUFFER a la printf. */
548 output_printf VPARAMS ((struct output_buffer *buffer, const char *msgid, ...))
550 #ifndef ANSI_PROTOTYPES
551 struct output_buffer *buffer;
556 VA_START (ap, msgid);
558 #ifndef ANSI_PROTOTYPES
559 buffer = va_arg (ap, struct output_buffer *);
560 msgid = va_arg (ap, const char *);
563 va_copy (buffer->format_args, ap);
564 output_notice (buffer, msgid);
565 va_end (buffer->format_args);
569 /* Format a MESSAGE into FILE. Do line wrapping, starting new lines
573 line_wrapper_printf VPARAMS ((FILE *file, const char *msgid, ...))
575 #ifndef ANSI_PROTOTYPES
579 output_buffer buffer;
581 init_output_buffer (&buffer, NULL, diagnostic_message_length_per_line);
582 VA_START (buffer.format_args, msgid);
584 #ifndef ANSI_PROTOTYPES
585 file = va_arg (buffer.format_args, FILE *);
586 msgid = va_arg (buffer.format_args, const char *);
589 output_notice (&buffer, msgid);
590 output_flush_on (&buffer, file);
592 va_end (buffer.format_args);
597 vline_wrapper_message_with_location (file, line, warn, msgid, ap)
604 output_buffer buffer;
606 init_output_buffer (&buffer, build_location_prefix (file, line, warn),
607 diagnostic_message_length_per_line);
608 va_copy (buffer.format_args, ap);
609 output_notice (&buffer, msgid);
610 output_flush_on (&buffer, stderr);
612 output_destroy_prefix (&buffer);
613 fputc ('\n', stderr);
617 /* Print the message MSGID in FILE. */
620 vnotice (file, msgid, ap)
625 vfprintf (file, _(msgid), ap);
628 /* Print MSGID on stderr. */
631 notice VPARAMS ((const char *msgid, ...))
633 #ifndef ANSI_PROTOTYPES
638 VA_START (ap, msgid);
640 #ifndef ANSI_PROTOTYPES
641 msgid = va_arg (ap, char *);
644 vnotice (stderr, msgid, ap);
648 /* Report FILE and LINE (or program name), and optionally just WARN. */
651 report_file_and_line (file, line, warn)
657 fprintf (stderr, "%s:%d: ", file, line);
659 fprintf (stderr, "%s: ", progname);
662 notice ("warning: ");
665 /* Print a message relevant to line LINE of file FILE. */
668 v_message_with_file_and_line (file, line, warn, msgid, ap)
675 report_file_and_line (file, line, warn);
676 vnotice (stderr, msgid, ap);
677 fputc ('\n', stderr);
680 /* Print a message relevant to the given DECL. */
683 v_message_with_decl (decl, warn, msgid, ap)
690 output_buffer buffer;
692 if (doing_line_wrapping ())
695 (&buffer, build_location_prefix
696 (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), warn),
697 diagnostic_message_length_per_line);
700 report_file_and_line (DECL_SOURCE_FILE (decl),
701 DECL_SOURCE_LINE (decl), warn);
703 /* Do magic to get around lack of varargs support for insertion
704 of arguments into existing list. We know that the decl is first;
705 we ass_u_me that it will be printed with "%s". */
707 for (p = _(msgid); *p; ++p)
713 else if (*(p + 1) != 's')
720 if (p > _(msgid)) /* Print the left-hand substring. */
722 if (doing_line_wrapping ())
723 output_printf (&buffer, "%.*s", (int)(p - _(msgid)), _(msgid));
725 fprintf (stderr, "%.*s", (int)(p - _(msgid)), _(msgid));
728 if (*p == '%') /* Print the name. */
730 const char *n = (DECL_NAME (decl)
731 ? (*decl_printable_name) (decl, 2)
732 : _("((anonymous))"));
733 if (doing_line_wrapping ())
734 output_add_string (&buffer, n);
740 if (ISALPHA (*(p - 1) & 0xFF))
745 if (*p) /* Print the rest of the message. */
747 if (doing_line_wrapping ())
749 va_copy (buffer.format_args, ap);
750 output_notice (&buffer, p);
751 va_copy (ap, buffer.format_args);
754 vfprintf (stderr, p, ap);
757 if (doing_line_wrapping())
759 output_flush_on (&buffer, stderr);
760 output_destroy_prefix (&buffer);
763 fputc ('\n', stderr);
766 /* Figure file and line of the given INSN. */
769 file_and_line_for_asm (insn, pfile, pline)
774 rtx body = PATTERN (insn);
777 /* Find the (or one of the) ASM_OPERANDS in the insn. */
778 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
779 asmop = SET_SRC (body);
780 else if (GET_CODE (body) == ASM_OPERANDS)
782 else if (GET_CODE (body) == PARALLEL
783 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
784 asmop = SET_SRC (XVECEXP (body, 0, 0));
785 else if (GET_CODE (body) == PARALLEL
786 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
787 asmop = XVECEXP (body, 0, 0);
793 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
794 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
798 *pfile = input_filename;
803 /* Report an error at line LINE of file FILE. */
806 v_error_with_file_and_line (file, line, msgid, ap)
813 report_error_function (file);
814 if (doing_line_wrapping ())
815 vline_wrapper_message_with_location (file, line, 0, msgid, ap);
817 v_message_with_file_and_line (file, line, 0, msgid, ap);
820 /* Report an error at the declaration DECL.
821 MSGID is a format string which uses %s to substitute the declaration
822 name; subsequent substitutions are a la printf. */
825 v_error_with_decl (decl, msgid, ap)
831 report_error_function (DECL_SOURCE_FILE (decl));
832 v_message_with_decl (decl, 0, msgid, ap);
836 /* Report an error at the line number of the insn INSN.
837 This is used only when INSN is an `asm' with operands,
838 and each ASM_OPERANDS records its own source file and line. */
841 v_error_for_asm (insn, msgid, ap)
850 file_and_line_for_asm (insn, &file, &line);
851 report_error_function (file);
852 v_message_with_file_and_line (file, line, 0, msgid, ap);
856 /* Report an error at the current line number. */
863 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
867 /* Report a fatal error at the current line number. Allow a front end to
868 intercept the message. */
870 static void (*fatal_function) PARAMS ((const char *, va_list));
877 if (fatal_function != 0)
878 (*fatal_function) (_(msgid), ap);
881 exit (FATAL_EXIT_CODE);
884 /* Report a warning at line LINE of file FILE. */
887 v_warning_with_file_and_line (file, line, msgid, ap)
895 report_error_function (file);
896 if (doing_line_wrapping ())
897 vline_wrapper_message_with_location (file, line, 1, msgid, ap);
899 v_message_with_file_and_line (file, line, 1, msgid, ap);
904 /* Report a warning at the declaration DECL.
905 MSGID is a format string which uses %s to substitute the declaration
906 name; subsequent substitutions are a la printf. */
909 v_warning_with_decl (decl, msgid, ap)
916 report_error_function (DECL_SOURCE_FILE (decl));
917 v_message_with_decl (decl, 1, msgid, ap);
922 /* Report a warning at the line number of the insn INSN.
923 This is used only when INSN is an `asm' with operands,
924 and each ASM_OPERANDS records its own source file and line. */
927 v_warning_for_asm (insn, msgid, ap)
937 file_and_line_for_asm (insn, &file, &line);
938 report_error_function (file);
939 v_message_with_file_and_line (file, line, 1, msgid, ap);
944 /* Report a warning at the current line number. */
951 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
954 /* These functions issue either warnings or errors depending on
962 if (flag_pedantic_errors)
965 vwarning (msgid, ap);
970 v_pedwarn_with_decl (decl, msgid, ap)
975 /* We don't want -pedantic-errors to cause the compilation to fail from
976 "errors" in system header files. Sometimes fixincludes can't fix what's
977 broken (eg: unsigned char bitfields - fixing it may change the alignment
978 which will cause programs to mysteriously fail because the C library
979 or kernel uses the original layout). There's no point in issuing a
980 warning either, it's just unnecessary noise. */
982 if (! DECL_IN_SYSTEM_HEADER (decl))
984 if (flag_pedantic_errors)
985 v_error_with_decl (decl, msgid, ap);
987 v_warning_with_decl (decl, msgid, ap);
993 v_pedwarn_with_file_and_line (file, line, msgid, ap)
999 if (flag_pedantic_errors)
1000 v_error_with_file_and_line (file, line, msgid, ap);
1002 v_warning_with_file_and_line (file, line, msgid, ap);
1006 /* Apologize for not implementing some feature. */
1015 fprintf (stderr, "%s:%d: ", input_filename, lineno);
1017 fprintf (stderr, "%s: ", progname);
1018 notice ("sorry, not implemented: ");
1019 vnotice (stderr, msgid, ap);
1020 fputc ('\n', stderr);
1024 /* Count an error or warning. Return 1 if the message should be printed. */
1027 count_error (warningp)
1030 if (warningp && inhibit_warnings)
1033 if (warningp && !warnings_are_errors)
1037 static int warning_message = 0;
1039 if (warningp && !warning_message)
1041 notice ("%s: warnings being treated as errors\n", progname);
1042 warning_message = 1;
1050 /* Print a diagnistic MSGID on FILE. */
1052 fnotice VPARAMS ((FILE *file, const char *msgid, ...))
1054 #ifndef ANSI_PROTOTYPES
1060 VA_START (ap, msgid);
1062 #ifndef ANSI_PROTOTYPES
1063 file = va_arg (ap, FILE *);
1064 msgid = va_arg (ap, const char *);
1067 vnotice (file, msgid, ap);
1072 /* Print a fatal error message. NAME is the text.
1073 Also include a system error message based on `errno'. */
1076 pfatal_with_name (name)
1079 fprintf (stderr, "%s: ", progname);
1081 exit (FATAL_EXIT_CODE);
1085 fatal_io_error (name)
1088 notice ("%s: %s: I/O error\n", progname, name);
1089 exit (FATAL_EXIT_CODE);
1092 /* Issue a pedantic warning MSGID. */
1094 pedwarn VPARAMS ((const char *msgid, ...))
1096 #ifndef ANSI_PROTOTYPES
1101 VA_START (ap, msgid);
1103 #ifndef ANSI_PROTOTYPES
1104 msgid = va_arg (ap, const char *);
1107 vpedwarn (msgid, ap);
1111 /* Issue a pedantic waring about DECL. */
1113 pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1115 #ifndef ANSI_PROTOTYPES
1121 VA_START (ap, msgid);
1123 #ifndef ANSI_PROTOTYPES
1124 decl = va_arg (ap, tree);
1125 msgid = va_arg (ap, const char *);
1128 v_pedwarn_with_decl (decl, msgid, ap);
1132 /* Same as above but within the context FILE and LINE. */
1134 pedwarn_with_file_and_line VPARAMS ((const char *file, int line,
1135 const char *msgid, ...))
1137 #ifndef ANSI_PROTOTYPES
1144 VA_START (ap, msgid);
1146 #ifndef ANSI_PROTOTYPES
1147 file = va_arg (ap, const char *);
1148 line = va_arg (ap, int);
1149 msgid = va_arg (ap, const char *);
1152 v_pedwarn_with_file_and_line (file, line, msgid, ap);
1156 /* Just apologize with MSGID. */
1158 sorry VPARAMS ((const char *msgid, ...))
1160 #ifndef ANSI_PROTOTYPES
1165 VA_START (ap, msgid);
1167 #ifndef ANSI_PROTOTYPES
1168 msgid = va_arg (ap, const char *);
1175 /* Called when the start of a function definition is parsed,
1176 this function prints on stderr the name of the function. */
1179 announce_function (decl)
1184 if (rtl_dump_and_exit)
1185 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1188 if (doing_line_wrapping ())
1190 (stderr, " %s", (*decl_printable_name) (decl, 2));
1192 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1195 need_error_newline = 1;
1196 last_error_function = current_function_decl;
1200 /* The default function to print out name of current function that caused
1204 default_print_error_function (file)
1207 if (last_error_function != current_function_decl)
1209 char *prefix = NULL;
1210 output_buffer buffer;
1213 prefix = build_message_string ("%s: ", file);
1215 if (doing_line_wrapping ())
1217 (&buffer, prefix, diagnostic_message_length_per_line);
1221 fprintf (stderr, "%s: ", file);
1224 if (current_function_decl == NULL)
1226 if (doing_line_wrapping ())
1227 output_printf (&buffer, "At top level:\n");
1229 notice ("At top level:\n");
1233 if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1235 if (doing_line_wrapping ())
1237 (&buffer, "In method `%s':\n",
1238 (*decl_printable_name) (current_function_decl, 2));
1240 notice ("In method `%s':\n",
1241 (*decl_printable_name) (current_function_decl, 2));
1245 if (doing_line_wrapping ())
1247 (&buffer, "In function `%s':\n",
1248 (*decl_printable_name) (current_function_decl, 2));
1250 notice ("In function `%s':\n",
1251 (*decl_printable_name) (current_function_decl, 2));
1255 last_error_function = current_function_decl;
1257 if (doing_line_wrapping ())
1258 output_flush_on (&buffer, stderr);
1260 free ((char*) prefix);
1264 /* Prints out, if necessary, the name of the current function
1265 that caused an error. Called from all error and warning functions.
1266 We ignore the FILE parameter, as it cannot be relied upon. */
1269 report_error_function (file)
1270 const char *file ATTRIBUTE_UNUSED;
1272 struct file_stack *p;
1274 if (need_error_newline)
1276 fprintf (stderr, "\n");
1277 need_error_newline = 0;
1280 if (input_file_stack && input_file_stack->next != 0
1281 && input_file_stack_tick != last_error_tick)
1283 for (p = input_file_stack->next; p; p = p->next)
1284 if (p == input_file_stack->next)
1285 notice ("In file included from %s:%d", p->name, p->line);
1287 notice (",\n from %s:%d", p->name, p->line);
1288 fprintf (stderr, ":\n");
1289 last_error_tick = input_file_stack_tick;
1292 (*print_error_function) (input_filename);
1296 error_with_file_and_line VPARAMS ((const char *file, int line,
1297 const char *msgid, ...))
1299 #ifndef ANSI_PROTOTYPES
1306 VA_START (ap, msgid);
1308 #ifndef ANSI_PROTOTYPES
1309 file = va_arg (ap, const char *);
1310 line = va_arg (ap, int);
1311 msgid = va_arg (ap, const char *);
1314 v_error_with_file_and_line (file, line, msgid, ap);
1319 error_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1321 #ifndef ANSI_PROTOTYPES
1327 VA_START (ap, msgid);
1329 #ifndef ANSI_PROTOTYPES
1330 decl = va_arg (ap, tree);
1331 msgid = va_arg (ap, const char *);
1334 v_error_with_decl (decl, msgid, ap);
1339 error_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
1341 #ifndef ANSI_PROTOTYPES
1347 VA_START (ap, msgid);
1349 #ifndef ANSI_PROTOTYPES
1350 insn = va_arg (ap, rtx);
1351 msgid = va_arg (ap, const char *);
1354 v_error_for_asm (insn, msgid, ap);
1359 error VPARAMS ((const char *msgid, ...))
1361 #ifndef ANSI_PROTOTYPES
1366 VA_START (ap, msgid);
1368 #ifndef ANSI_PROTOTYPES
1369 msgid = va_arg (ap, const char *);
1376 /* Set the function to call when a fatal error occurs. */
1379 set_fatal_function (f)
1380 void (*f) PARAMS ((const char *, va_list));
1386 fatal VPARAMS ((const char *msgid, ...))
1388 #ifndef ANSI_PROTOTYPES
1393 VA_START (ap, msgid);
1395 #ifndef ANSI_PROTOTYPES
1396 msgid = va_arg (ap, const char *);
1404 _fatal_insn (msgid, insn, file, line, function)
1409 const char *function;
1411 error ("%s", msgid);
1413 fancy_abort (file, line, function);
1417 _fatal_insn_not_found (insn, file, line, function)
1421 const char *function;
1423 if (INSN_CODE (insn) < 0)
1424 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1426 _fatal_insn ("Insn does not satisfy its constraints:",
1427 insn, file, line, function);
1431 warning_with_file_and_line VPARAMS ((const char *file, int line,
1432 const char *msgid, ...))
1434 #ifndef ANSI_PROTOTYPES
1441 VA_START (ap, msgid);
1443 #ifndef ANSI_PROTOTYPES
1444 file = va_arg (ap, const char *);
1445 line = va_arg (ap, int);
1446 msgid = va_arg (ap, const char *);
1449 v_warning_with_file_and_line (file, line, msgid, ap);
1454 warning_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1456 #ifndef ANSI_PROTOTYPES
1462 VA_START (ap, msgid);
1464 #ifndef ANSI_PROTOTYPES
1465 decl = va_arg (ap, tree);
1466 msgid = va_arg (ap, const char *);
1469 v_warning_with_decl (decl, msgid, ap);
1474 warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
1476 #ifndef ANSI_PROTOTYPES
1482 VA_START (ap, msgid);
1484 #ifndef ANSI_PROTOTYPES
1485 insn = va_arg (ap, rtx);
1486 msgid = va_arg (ap, const char *);
1489 v_warning_for_asm (insn, msgid, ap);
1494 warning VPARAMS ((const char *msgid, ...))
1496 #ifndef ANSI_PROTOTYPES
1501 VA_START (ap, msgid);
1503 #ifndef ANSI_PROTOTYPES
1504 msgid = va_arg (ap, const char *);
1507 vwarning (msgid, ap);