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 const char *vbuild_message_string PARAMS ((const char *, va_list));
49 static const char *build_message_string PARAMS ((const char *, ...))
51 static const 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 verror PARAMS ((const char *, va_list));
68 static void vfatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
69 static void v_warning_with_file_and_line PARAMS ((const char *, int,
70 const char *, va_list));
71 static void v_warning_with_decl PARAMS ((tree, const char *, va_list));
72 static void v_warning_for_asm PARAMS ((rtx, const char *, va_list));
73 static void vwarning PARAMS ((const char *, va_list));
74 static void vpedwarn PARAMS ((const char *, va_list));
75 static void v_pedwarn_with_decl PARAMS ((tree, const char *, va_list));
76 static void v_pedwarn_with_file_and_line PARAMS ((const char *, int,
77 const char *, va_list));
78 static void vsorry PARAMS ((const char *, va_list));
79 static void report_file_and_line PARAMS ((const char *, int, int));
80 static void vnotice PARAMS ((FILE *, const char *, va_list));
82 extern int rtl_dump_and_exit;
83 extern int inhibit_warnings;
84 extern int warnings_are_errors;
85 extern int warningcount;
86 extern int errorcount;
88 /* Front-end specific tree formatter, if non-NULL. */
89 printer_fn lang_printer = NULL;
91 static int need_error_newline;
93 /* Function of last error message;
94 more generally, function such that if next error message is in it
95 then we don't have to mention the function name. */
96 static tree last_error_function = NULL;
98 /* Used to detect when input_file_stack has changed since last described. */
99 static int last_error_tick;
101 /* Called by report_error_function to print out function name.
102 * Default may be overridden by language front-ends. */
104 void (*print_error_function) PARAMS ((const char *)) =
105 default_print_error_function;
107 /* Maximum characters per line in automatic line wrapping mode.
108 Zero means don't wrap lines. */
110 static int output_maximum_width = 0;
112 /* Predicate. Return 1 if we're in automatic line wrapping mode. */
115 doing_line_wrapping ()
117 return output_maximum_width > 0;
120 /* Set Maximum characters per line in automatic line wrapping mode. */
123 set_message_length (n)
126 output_maximum_width = n;
129 /* Returns true if BUFFER is in line-wrappind mode. */
131 output_is_line_wrapping (buffer)
132 output_buffer *buffer;
134 return buffer->ideal_maximum_length > 0;
137 /* Return BUFFER's prefix. */
139 output_get_prefix (buffer)
140 const output_buffer *buffer;
142 return buffer->prefix;
145 /* Subroutine of output_set_maximum_length. Set up BUFFER's
146 internal maximum characters per line. */
148 set_real_maximum_length (buffer)
149 output_buffer *buffer;
151 /* If we're told not to wrap lines then do the obvious thing. */
152 if (! output_is_line_wrapping (buffer))
153 buffer->maximum_length = buffer->ideal_maximum_length;
156 int prefix_length = buffer->prefix ? strlen (buffer->prefix) : 0;
157 /* If the prefix is ridiculously too long, output at least
159 if (buffer->ideal_maximum_length - prefix_length < 32)
160 buffer->maximum_length = buffer->ideal_maximum_length + 32;
162 buffer->maximum_length = buffer->ideal_maximum_length;
166 /* Sets the number of maximum characters per line BUFFER can output
167 in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
169 output_set_maximum_length (buffer, length)
170 output_buffer *buffer;
173 buffer->ideal_maximum_length = length;
174 set_real_maximum_length (buffer);
177 /* Sets BUFFER's PREFIX. */
179 output_set_prefix (buffer, prefix)
180 output_buffer *buffer;
183 buffer->prefix = prefix;
184 set_real_maximum_length (buffer);
187 /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
188 characters per line. */
190 init_output_buffer (buffer, prefix, maximum_length)
191 output_buffer *buffer;
195 obstack_init (&buffer->obstack);
196 buffer->ideal_maximum_length = maximum_length;
197 buffer->line_length = 0;
198 output_set_prefix (buffer, prefix);
200 buffer->cursor = NULL;
201 buffer->format_args = NULL;
204 /* Reinitialize BUFFER. */
206 output_clear (buffer)
207 output_buffer *buffer;
209 obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
210 buffer->line_length = 0;
211 buffer->cursor = NULL;
212 buffer->format_args = NULL;
215 /* Finishes to construct a NULL-terminated character string representing
216 the BUFFERed message. */
218 output_finish (buffer)
219 output_buffer *buffer;
221 obstack_1grow (&buffer->obstack, '\0');
222 return (const char *) obstack_finish (&buffer->obstack);
225 /* Return the amount of characters BUFFER can accept to
228 output_space_left (buffer)
229 const output_buffer *buffer;
231 return buffer->maximum_length - buffer->line_length;
234 /* Write out BUFFER's prefix. */
236 output_emit_prefix (buffer)
237 output_buffer *buffer;
241 buffer->line_length = strlen (buffer->prefix);
242 obstack_grow (&buffer->obstack, buffer->prefix, buffer->line_length);
246 /* Have BUFFER start a new line. */
248 output_add_newline (buffer)
249 output_buffer *buffer;
251 obstack_1grow (&buffer->obstack, '\n');
252 buffer->line_length = 0;
255 /* Appends a character to BUFFER. */
257 output_add_character (buffer, c)
258 output_buffer *buffer;
261 if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
262 output_add_newline (buffer);
263 obstack_1grow (&buffer->obstack, c);
264 ++buffer->line_length;
267 /* Adds a space to BUFFER. */
269 output_add_space (buffer)
270 output_buffer *buffer;
272 if (output_is_line_wrapping (buffer) && output_space_left (buffer) <= 0)
274 output_add_newline (buffer);
277 obstack_1grow (&buffer->obstack, ' ');
278 ++buffer->line_length;
281 /* Add the stringified version of an integer to BUFFER. */
283 output_add_integer (buffer, i)
284 output_buffer *buffer;
287 /* This must be large enough to hold any printed integer or
288 floating-point value. */
289 static char digit_buffer[128];
291 sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, i);
292 output_add_string (buffer, digit_buffer);
295 /* Append a string deliminated by START and END to BUFFER. No wrapping is
296 done. The caller must ensure that it is safe to do so. */
299 output_append (buffer, start, end)
300 output_buffer *buffer;
306 /* Emit prefix and skip whitespace if we're starting a new line. */
307 if (buffer->line_length == 0)
309 output_emit_prefix (buffer);
310 while (start != end && *start == ' ')
314 obstack_grow (&buffer->obstack, start, n);
315 buffer->line_length += n;
318 /* Wrap a STRing into BUFFER. */
321 output_add_string (buffer, str)
322 output_buffer *buffer;
327 if (!output_is_line_wrapping (buffer))
328 output_append (buffer, str, str + strlen (str));
331 while (*p && *p != ' ' && *p != '\n')
334 if (p - str < output_space_left (buffer))
335 output_append (buffer, str, p);
338 output_add_newline (buffer);
339 output_append (buffer, str, p);
342 while (*p && *p == '\n')
344 output_add_newline (buffer);
352 /* Flush the content of BUFFER onto FILE and reinitialize BUFFER. */
355 output_flush_on (buffer, file)
356 output_buffer *buffer;
359 const char *text = output_finish (buffer);
361 output_clear (buffer);
364 /* Format MESSAGE into BUFFER. */
366 output_format (buffer, msg)
367 output_buffer *buffer;
370 for (buffer->cursor = msg; *buffer->cursor; ++buffer->cursor)
373 if (*buffer->cursor != '%')
375 output_add_character (buffer, *buffer->cursor);
379 /* We got a '%'. Let's see what happens. */
382 /* Let's handle the traditional cases. */
383 if (*buffer->cursor == 's')
384 output_add_string (buffer, va_arg (buffer->format_args, const char *));
385 else if (*buffer->cursor == 'd')
386 output_add_integer (buffer, va_arg (buffer->format_args, int));
387 else if (*buffer->cursor == '%')
388 /* It was a '%%'. Just output a '%'. */
389 output_add_character (buffer, '%');
390 else if (lang_printer)
391 (*lang_printer) (buffer);
394 /* Hmmm. The front-end failed to install a format translator
395 but called us with an unrecognized format. Sorry. */
399 output_finish (buffer);
403 vbuild_message_string (msgid, ap)
409 vasprintf (&str, msgid, ap);
413 /* Return a malloc'd string containing MSGID formatted a la
414 printf. The caller is reponsible for freeing the memory. */
417 build_message_string VPARAMS ((const char *msgid, ...))
419 #ifndef ANSI_PROTOTYPES
425 VA_START (ap, msgid);
427 #ifndef ANSI_PROTOTYPES
428 msgid = va_arg (ap, const char *);
431 str = vbuild_message_string (msgid, ap);
439 /* Return a malloc'd string describing a location. The caller is
440 responsible for freeing the memory. */
443 build_location_prefix (file, line, warn)
451 return build_message_string ("%s:%d: warning: ", file, line);
453 return build_message_string ("%s:%d: ", file, line);
458 return build_message_string ("%s: warning: ", progname);
460 return build_message_string ("%s: ", progname);
464 /* Format a MESSAGE into BUFFER. Automatically wrap lines. */
467 output_notice (buffer, msgid)
468 output_buffer *buffer;
471 const char *message = vbuild_message_string (msgid, buffer->format_args);
473 output_add_string (buffer, message);
474 free ((char *) message);
478 /* Format a message into BUFFER a la printf. */
481 output_printf VPARAMS ((struct output_buffer *buffer, const char *msgid, ...))
483 #ifndef ANSI_PROTOTYPES
484 struct output_buffer *buffer;
489 VA_START (ap, msgid);
491 #ifndef ANSI_PROTOTYPES
492 buffer = va_arg (ap, struct output_buffer *);
493 msgid = va_arg (ap, const char *);
496 buffer->format_args = ap;
497 output_notice (buffer, msgid);
498 va_end (buffer->format_args);
502 /* Format a MESSAGE into FILE. Do line wrapping, starting new lines
506 line_wrapper_printf VPARAMS ((FILE *file, const char *msgid, ...))
508 #ifndef ANSI_PROTOTYPES
512 output_buffer buffer;
515 VA_START (ap, msgid);
517 #ifndef ANSI_PROTOTYPES
518 file = va_arg (ap, FILE *);
519 msgid = va_arg (ap, const char *);
522 init_output_buffer (&buffer, NULL, output_maximum_width);
523 buffer.format_args = ap;
524 output_notice (&buffer, msgid);
525 output_flush_on (&buffer, file);
527 va_end (buffer.format_args);
532 vline_wrapper_message_with_location (file, line, warn, msgid, ap)
539 output_buffer buffer;
542 (&buffer, build_location_prefix (file, line, warn), output_maximum_width);
543 buffer.format_args = ap;
544 output_notice (&buffer, msgid);
545 output_flush_on (&buffer, stderr);
547 free ((char*) output_get_prefix (&buffer));
548 fputc ('\n', stderr);
552 /* Print the message MSGID in FILE. */
555 vnotice (file, msgid, ap)
560 vfprintf (file, _(msgid), ap);
563 /* Print MSGID on stderr. */
566 notice VPARAMS ((const char *msgid, ...))
568 #ifndef ANSI_PROTOTYPES
573 VA_START (ap, msgid);
575 #ifndef ANSI_PROTOTYPES
576 msgid = va_arg (ap, char *);
579 vnotice (stderr, msgid, ap);
583 /* Report FILE and LINE (or program name), and optionally just WARN. */
586 report_file_and_line (file, line, warn)
592 fprintf (stderr, "%s:%d: ", file, line);
594 fprintf (stderr, "%s: ", progname);
597 notice ("warning: ");
600 /* Print a message relevant to line LINE of file FILE. */
603 v_message_with_file_and_line (file, line, warn, msgid, ap)
610 report_file_and_line (file, line, warn);
611 vnotice (stderr, msgid, ap);
612 fputc ('\n', stderr);
615 /* Print a message relevant to the given DECL. */
618 v_message_with_decl (decl, warn, msgid, ap)
625 output_buffer buffer;
627 if (doing_line_wrapping ())
630 (&buffer, build_location_prefix
631 (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl), warn),
632 output_maximum_width);
635 report_file_and_line (DECL_SOURCE_FILE (decl),
636 DECL_SOURCE_LINE (decl), warn);
638 /* Do magic to get around lack of varargs support for insertion
639 of arguments into existing list. We know that the decl is first;
640 we ass_u_me that it will be printed with "%s". */
642 for (p = _(msgid); *p; ++p)
648 else if (*(p + 1) != 's')
655 if (p > _(msgid)) /* Print the left-hand substring. */
657 if (doing_line_wrapping ())
658 output_printf (&buffer, "%.*s", (int)(p - _(msgid)), _(msgid));
660 fprintf (stderr, "%.*s", (int)(p - _(msgid)), _(msgid));
663 if (*p == '%') /* Print the name. */
665 const char *n = (DECL_NAME (decl)
666 ? (*decl_printable_name) (decl, 2)
668 if (doing_line_wrapping ())
669 output_add_string (&buffer, n);
675 if (ISALPHA (*(p - 1) & 0xFF))
680 if (*p) /* Print the rest of the message. */
682 if (doing_line_wrapping ())
684 buffer.format_args = ap;
685 output_notice (&buffer, p);
686 ap = buffer.format_args;
689 vfprintf (stderr, p, ap);
692 if (doing_line_wrapping())
694 output_flush_on (&buffer, stderr);
695 free ((char *) output_get_prefix (&buffer));
698 fputc ('\n', stderr);
701 /* Figure file and line of the given INSN. */
704 file_and_line_for_asm (insn, pfile, pline)
709 rtx body = PATTERN (insn);
712 /* Find the (or one of the) ASM_OPERANDS in the insn. */
713 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
714 asmop = SET_SRC (body);
715 else if (GET_CODE (body) == ASM_OPERANDS)
717 else if (GET_CODE (body) == PARALLEL
718 && GET_CODE (XVECEXP (body, 0, 0)) == SET)
719 asmop = SET_SRC (XVECEXP (body, 0, 0));
720 else if (GET_CODE (body) == PARALLEL
721 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
722 asmop = XVECEXP (body, 0, 0);
728 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop);
729 *pline = ASM_OPERANDS_SOURCE_LINE (asmop);
733 *pfile = input_filename;
738 /* Report an error at line LINE of file FILE. */
741 v_error_with_file_and_line (file, line, msgid, ap)
748 report_error_function (file);
749 if (doing_line_wrapping ())
750 vline_wrapper_message_with_location (file, line, 0, msgid, ap);
752 v_message_with_file_and_line (file, line, 0, msgid, ap);
755 /* Report an error at the declaration DECL.
756 MSGID is a format string which uses %s to substitute the declaration
757 name; subsequent substitutions are a la printf. */
760 v_error_with_decl (decl, msgid, ap)
766 report_error_function (DECL_SOURCE_FILE (decl));
767 v_message_with_decl (decl, 0, msgid, ap);
771 /* Report an error at the line number of the insn INSN.
772 This is used only when INSN is an `asm' with operands,
773 and each ASM_OPERANDS records its own source file and line. */
776 v_error_for_asm (insn, msgid, ap)
785 file_and_line_for_asm (insn, &file, &line);
786 report_error_function (file);
787 v_message_with_file_and_line (file, line, 0, msgid, ap);
791 /* Report an error at the current line number. */
798 v_error_with_file_and_line (input_filename, lineno, msgid, ap);
802 /* Report a fatal error at the current line number. Allow a front end to
803 intercept the message. */
805 static void (*fatal_function) PARAMS ((const char *, va_list));
812 if (fatal_function != 0)
813 (*fatal_function) (_(msgid), ap);
816 exit (FATAL_EXIT_CODE);
819 /* Report a warning at line LINE of file FILE. */
822 v_warning_with_file_and_line (file, line, msgid, ap)
830 report_error_function (file);
831 if (doing_line_wrapping ())
832 vline_wrapper_message_with_location (file, line, 1, msgid, ap);
834 v_message_with_file_and_line (file, line, 1, msgid, ap);
839 /* Report a warning at the declaration DECL.
840 MSGID is a format string which uses %s to substitute the declaration
841 name; subsequent substitutions are a la printf. */
844 v_warning_with_decl (decl, msgid, ap)
851 report_error_function (DECL_SOURCE_FILE (decl));
852 v_message_with_decl (decl, 1, msgid, ap);
857 /* Report a warning at the line number of the insn INSN.
858 This is used only when INSN is an `asm' with operands,
859 and each ASM_OPERANDS records its own source file and line. */
862 v_warning_for_asm (insn, msgid, ap)
872 file_and_line_for_asm (insn, &file, &line);
873 report_error_function (file);
874 v_message_with_file_and_line (file, line, 1, msgid, ap);
879 /* Report a warning at the current line number. */
886 v_warning_with_file_and_line (input_filename, lineno, msgid, ap);
889 /* These functions issue either warnings or errors depending on
897 if (flag_pedantic_errors)
900 vwarning (msgid, ap);
905 v_pedwarn_with_decl (decl, msgid, ap)
910 /* We don't want -pedantic-errors to cause the compilation to fail from
911 "errors" in system header files. Sometimes fixincludes can't fix what's
912 broken (eg: unsigned char bitfields - fixing it may change the alignment
913 which will cause programs to mysteriously fail because the C library
914 or kernel uses the original layout). There's no point in issuing a
915 warning either, it's just unnecessary noise. */
917 if (! DECL_IN_SYSTEM_HEADER (decl))
919 if (flag_pedantic_errors)
920 v_error_with_decl (decl, msgid, ap);
922 v_warning_with_decl (decl, msgid, ap);
928 v_pedwarn_with_file_and_line (file, line, msgid, ap)
934 if (flag_pedantic_errors)
935 v_error_with_file_and_line (file, line, msgid, ap);
937 v_warning_with_file_and_line (file, line, msgid, ap);
941 /* Apologize for not implementing some feature. */
950 fprintf (stderr, "%s:%d: ", input_filename, lineno);
952 fprintf (stderr, "%s: ", progname);
953 notice ("sorry, not implemented: ");
954 vnotice (stderr, msgid, ap);
955 fputc ('\n', stderr);
959 /* Count an error or warning. Return 1 if the message should be printed. */
962 count_error (warningp)
965 if (warningp && inhibit_warnings)
968 if (warningp && !warnings_are_errors)
972 static int warning_message = 0;
974 if (warningp && !warning_message)
976 notice ("%s: warnings being treated as errors\n", progname);
985 /* Print a diagnistic MSGID on FILE. */
987 fnotice VPARAMS ((FILE *file, const char *msgid, ...))
989 #ifndef ANSI_PROTOTYPES
995 VA_START (ap, msgid);
997 #ifndef ANSI_PROTOTYPES
998 file = va_arg (ap, FILE *);
999 msgid = va_arg (ap, const char *);
1002 vnotice (file, msgid, ap);
1007 /* Print a fatal error message. NAME is the text.
1008 Also include a system error message based on `errno'. */
1011 pfatal_with_name (name)
1014 fprintf (stderr, "%s: ", progname);
1016 exit (FATAL_EXIT_CODE);
1020 fatal_io_error (name)
1023 notice ("%s: %s: I/O error\n", progname, name);
1024 exit (FATAL_EXIT_CODE);
1027 /* Issue a pedantic warning MSGID. */
1029 pedwarn VPARAMS ((const char *msgid, ...))
1031 #ifndef ANSI_PROTOTYPES
1036 VA_START (ap, msgid);
1038 #ifndef ANSI_PROTOTYPES
1039 msgid = va_arg (ap, const char *);
1042 vpedwarn (msgid, ap);
1046 /* Issue a pedantic waring about DECL. */
1048 pedwarn_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1050 #ifndef ANSI_PROTOTYPES
1056 VA_START (ap, msgid);
1058 #ifndef ANSI_PROTOTYPES
1059 decl = va_arg (ap, tree);
1060 msgid = va_arg (ap, const char *);
1063 v_pedwarn_with_decl (decl, msgid, ap);
1067 /* Same as above but within the context FILE and LINE. */
1069 pedwarn_with_file_and_line VPARAMS ((const char *file, int line,
1070 const char *msgid, ...))
1072 #ifndef ANSI_PROTOTYPES
1079 VA_START (ap, msgid);
1081 #ifndef ANSI_PROTOTYPES
1082 file = va_arg (ap, const char *);
1083 line = va_arg (ap, int);
1084 msgid = va_arg (ap, const char *);
1087 v_pedwarn_with_file_and_line (file, line, msgid, ap);
1091 /* Just apologize with MSGID. */
1093 sorry VPARAMS ((const char *msgid, ...))
1095 #ifndef ANSI_PROTOTYPES
1100 VA_START (ap, msgid);
1102 #ifndef ANSI_PROTOTYPES
1103 msgid = va_arg (ap, const char *);
1110 /* Called when the start of a function definition is parsed,
1111 this function prints on stderr the name of the function. */
1114 announce_function (decl)
1119 if (rtl_dump_and_exit)
1120 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
1123 if (doing_line_wrapping ())
1125 (stderr, " %s", (*decl_printable_name) (decl, 2));
1127 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2));
1130 need_error_newline = 1;
1131 last_error_function = current_function_decl;
1135 /* The default function to print out name of current function that caused
1139 default_print_error_function (file)
1142 if (last_error_function != current_function_decl)
1144 const char *prefix = NULL;
1145 output_buffer buffer;
1148 prefix = build_message_string ("%s: ", file);
1150 if (doing_line_wrapping ())
1151 init_output_buffer (&buffer, prefix, output_maximum_width);
1155 fprintf (stderr, "%s: ", file);
1158 if (current_function_decl == NULL)
1160 if (doing_line_wrapping ())
1161 output_printf (&buffer, "At top level:\n");
1163 notice ("At top level:\n");
1167 if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
1169 if (doing_line_wrapping ())
1171 (&buffer, "In method `%s':\n",
1172 (*decl_printable_name) (current_function_decl, 2));
1174 notice ("In method `%s':\n",
1175 (*decl_printable_name) (current_function_decl, 2));
1179 if (doing_line_wrapping ())
1181 (&buffer, "In function `%s':\n",
1182 (*decl_printable_name) (current_function_decl, 2));
1184 notice ("In function `%s':\n",
1185 (*decl_printable_name) (current_function_decl, 2));
1189 last_error_function = current_function_decl;
1191 if (doing_line_wrapping ())
1192 output_flush_on (&buffer, stderr);
1194 free ((char*) prefix);
1198 /* Prints out, if necessary, the name of the current function
1199 that caused an error. Called from all error and warning functions.
1200 We ignore the FILE parameter, as it cannot be relied upon. */
1203 report_error_function (file)
1204 const char *file ATTRIBUTE_UNUSED;
1206 struct file_stack *p;
1208 if (need_error_newline)
1210 fprintf (stderr, "\n");
1211 need_error_newline = 0;
1214 if (input_file_stack && input_file_stack->next != 0
1215 && input_file_stack_tick != last_error_tick)
1217 for (p = input_file_stack->next; p; p = p->next)
1218 if (p == input_file_stack->next)
1219 notice ("In file included from %s:%d", p->name, p->line);
1221 notice (",\n from %s:%d", p->name, p->line);
1222 fprintf (stderr, ":\n");
1223 last_error_tick = input_file_stack_tick;
1226 (*print_error_function) (input_filename);
1230 error_with_file_and_line VPARAMS ((const char *file, int line,
1231 const char *msgid, ...))
1233 #ifndef ANSI_PROTOTYPES
1240 VA_START (ap, msgid);
1242 #ifndef ANSI_PROTOTYPES
1243 file = va_arg (ap, const char *);
1244 line = va_arg (ap, int);
1245 msgid = va_arg (ap, const char *);
1248 v_error_with_file_and_line (file, line, msgid, ap);
1253 error_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1255 #ifndef ANSI_PROTOTYPES
1261 VA_START (ap, msgid);
1263 #ifndef ANSI_PROTOTYPES
1264 decl = va_arg (ap, tree);
1265 msgid = va_arg (ap, const char *);
1268 v_error_with_decl (decl, msgid, ap);
1273 error_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
1275 #ifndef ANSI_PROTOTYPES
1281 VA_START (ap, msgid);
1283 #ifndef ANSI_PROTOTYPES
1284 insn = va_arg (ap, rtx);
1285 msgid = va_arg (ap, const char *);
1288 v_error_for_asm (insn, msgid, ap);
1293 error VPARAMS ((const char *msgid, ...))
1295 #ifndef ANSI_PROTOTYPES
1300 VA_START (ap, msgid);
1302 #ifndef ANSI_PROTOTYPES
1303 msgid = va_arg (ap, const char *);
1310 /* Set the function to call when a fatal error occurs. */
1313 set_fatal_function (f)
1314 void (*f) PARAMS ((const char *, va_list));
1320 fatal VPARAMS ((const char *msgid, ...))
1322 #ifndef ANSI_PROTOTYPES
1327 VA_START (ap, msgid);
1329 #ifndef ANSI_PROTOTYPES
1330 msgid = va_arg (ap, const char *);
1338 _fatal_insn (msgid, insn, file, line, function)
1343 const char *function;
1345 error ("%s", msgid);
1347 fancy_abort (file, line, function);
1351 _fatal_insn_not_found (insn, file, line, function)
1355 const char *function;
1357 if (INSN_CODE (insn) < 0)
1358 _fatal_insn ("Unrecognizable insn:", insn, file, line, function);
1360 _fatal_insn ("Insn does not satisfy its constraints:",
1361 insn, file, line, function);
1365 warning_with_file_and_line VPARAMS ((const char *file, int line,
1366 const char *msgid, ...))
1368 #ifndef ANSI_PROTOTYPES
1375 VA_START (ap, msgid);
1377 #ifndef ANSI_PROTOTYPES
1378 file = va_arg (ap, const char *);
1379 line = va_arg (ap, int);
1380 msgid = va_arg (ap, const char *);
1383 v_warning_with_file_and_line (file, line, msgid, ap);
1388 warning_with_decl VPARAMS ((tree decl, const char *msgid, ...))
1390 #ifndef ANSI_PROTOTYPES
1396 VA_START (ap, msgid);
1398 #ifndef ANSI_PROTOTYPES
1399 decl = va_arg (ap, tree);
1400 msgid = va_arg (ap, const char *);
1403 v_warning_with_decl (decl, msgid, ap);
1408 warning_for_asm VPARAMS ((rtx insn, const char *msgid, ...))
1410 #ifndef ANSI_PROTOTYPES
1416 VA_START (ap, msgid);
1418 #ifndef ANSI_PROTOTYPES
1419 insn = va_arg (ap, rtx);
1420 msgid = va_arg (ap, const char *);
1423 v_warning_for_asm (insn, msgid, ap);
1428 warning VPARAMS ((const char *msgid, ...))
1430 #ifndef ANSI_PROTOTYPES
1435 VA_START (ap, msgid);
1437 #ifndef ANSI_PROTOTYPES
1438 msgid = va_arg (ap, const char *);
1441 vwarning (msgid, ap);