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 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));
81 static void set_real_maximum_length
PARAMS ((output_buffer
*));
83 extern int rtl_dump_and_exit
;
84 extern int inhibit_warnings
;
85 extern int warnings_are_errors
;
86 extern int warningcount
;
87 extern int errorcount
;
89 /* Front-end specific tree formatter, if non-NULL. */
90 printer_fn lang_printer
= NULL
;
92 static int need_error_newline
;
94 /* Function of last error message;
95 more generally, function such that if next error message is in it
96 then we don't have to mention the function name. */
97 static tree last_error_function
= NULL
;
99 /* Used to detect when input_file_stack has changed since last described. */
100 static int last_error_tick
;
102 /* Called by report_error_function to print out function name.
103 * Default may be overridden by language front-ends. */
105 void (*print_error_function
) PARAMS ((const char *)) =
106 default_print_error_function
;
108 /* Maximum characters per line in automatic line wrapping mode.
109 Zero means don't wrap lines. */
111 static int output_maximum_width
= 0;
113 /* Predicate. Return 1 if we're in automatic line wrapping mode. */
116 doing_line_wrapping ()
118 return output_maximum_width
> 0;
121 /* Set Maximum characters per line in automatic line wrapping mode. */
124 set_message_length (n
)
127 output_maximum_width
= n
;
130 /* Returns true if BUFFER is in line-wrappind mode. */
132 output_is_line_wrapping (buffer
)
133 output_buffer
*buffer
;
135 return buffer
->ideal_maximum_length
> 0;
138 /* Return BUFFER's prefix. */
140 output_get_prefix (buffer
)
141 const output_buffer
*buffer
;
143 return buffer
->prefix
;
146 /* Subroutine of output_set_maximum_length. Set up BUFFER's
147 internal maximum characters per line. */
149 set_real_maximum_length (buffer
)
150 output_buffer
*buffer
;
152 /* If we're told not to wrap lines then do the obvious thing. */
153 if (! output_is_line_wrapping (buffer
))
154 buffer
->maximum_length
= buffer
->ideal_maximum_length
;
157 int prefix_length
= buffer
->prefix
? strlen (buffer
->prefix
) : 0;
158 /* If the prefix is ridiculously too long, output at least
160 if (buffer
->ideal_maximum_length
- prefix_length
< 32)
161 buffer
->maximum_length
= buffer
->ideal_maximum_length
+ 32;
163 buffer
->maximum_length
= buffer
->ideal_maximum_length
;
167 /* Sets the number of maximum characters per line BUFFER can output
168 in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
170 output_set_maximum_length (buffer
, length
)
171 output_buffer
*buffer
;
174 buffer
->ideal_maximum_length
= length
;
175 set_real_maximum_length (buffer
);
178 /* Sets BUFFER's PREFIX. */
180 output_set_prefix (buffer
, prefix
)
181 output_buffer
*buffer
;
184 buffer
->prefix
= prefix
;
185 set_real_maximum_length (buffer
);
188 /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
189 characters per line. */
191 init_output_buffer (buffer
, prefix
, maximum_length
)
192 output_buffer
*buffer
;
196 obstack_init (&buffer
->obstack
);
197 buffer
->ideal_maximum_length
= maximum_length
;
198 buffer
->line_length
= 0;
199 output_set_prefix (buffer
, prefix
);
201 buffer
->cursor
= 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
;
214 /* Finishes to construct a NULL-terminated character string representing
215 the BUFFERed message. */
217 output_finish (buffer
)
218 output_buffer
*buffer
;
220 obstack_1grow (&buffer
->obstack
, '\0');
221 return (const char *) obstack_finish (&buffer
->obstack
);
224 /* Return the amount of characters BUFFER can accept to
227 output_space_left (buffer
)
228 const output_buffer
*buffer
;
230 return buffer
->maximum_length
- buffer
->line_length
;
233 /* Write out BUFFER's prefix. */
235 output_emit_prefix (buffer
)
236 output_buffer
*buffer
;
240 buffer
->line_length
= strlen (buffer
->prefix
);
241 obstack_grow (&buffer
->obstack
, buffer
->prefix
, buffer
->line_length
);
245 /* Have BUFFER start a new line. */
247 output_add_newline (buffer
)
248 output_buffer
*buffer
;
250 obstack_1grow (&buffer
->obstack
, '\n');
251 buffer
->line_length
= 0;
254 /* Appends a character to BUFFER. */
256 output_add_character (buffer
, c
)
257 output_buffer
*buffer
;
260 if (output_is_line_wrapping (buffer
) && output_space_left (buffer
) <= 0)
261 output_add_newline (buffer
);
262 obstack_1grow (&buffer
->obstack
, c
);
263 ++buffer
->line_length
;
266 /* Adds a space to BUFFER. */
268 output_add_space (buffer
)
269 output_buffer
*buffer
;
271 if (output_is_line_wrapping (buffer
) && output_space_left (buffer
) <= 0)
273 output_add_newline (buffer
);
276 obstack_1grow (&buffer
->obstack
, ' ');
277 ++buffer
->line_length
;
280 /* Add the stringified version of an integer to BUFFER. */
282 output_add_integer (buffer
, i
)
283 output_buffer
*buffer
;
286 /* This must be large enough to hold any printed integer or
287 floating-point value. */
288 static char digit_buffer
[128];
290 sprintf (digit_buffer
, HOST_WIDE_INT_PRINT_DEC
, i
);
291 output_add_string (buffer
, digit_buffer
);
294 /* Append a string deliminated by START and END to BUFFER. No wrapping is
295 done. The caller must ensure that it is safe to do so. */
298 output_append (buffer
, start
, end
)
299 output_buffer
*buffer
;
305 /* Emit prefix and skip whitespace if we're starting a new line. */
306 if (buffer
->line_length
== 0)
308 output_emit_prefix (buffer
);
309 while (start
!= end
&& *start
== ' ')
313 obstack_grow (&buffer
->obstack
, start
, n
);
314 buffer
->line_length
+= n
;
317 /* Wrap a STRing into BUFFER. */
320 output_add_string (buffer
, str
)
321 output_buffer
*buffer
;
326 if (!output_is_line_wrapping (buffer
))
327 output_append (buffer
, str
, str
+ strlen (str
));
330 while (*p
&& *p
!= ' ' && *p
!= '\n')
333 if (p
- str
< output_space_left (buffer
))
334 output_append (buffer
, str
, p
);
337 output_add_newline (buffer
);
338 output_append (buffer
, str
, p
);
341 while (*p
&& *p
== '\n')
343 output_add_newline (buffer
);
351 /* Flush the content of BUFFER onto FILE and reinitialize BUFFER. */
354 output_flush_on (buffer
, file
)
355 output_buffer
*buffer
;
358 const char *text
= output_finish (buffer
);
360 output_clear (buffer
);
363 /* Format MESSAGE into BUFFER. */
365 output_format (buffer
, msg
)
366 output_buffer
*buffer
;
369 for (buffer
->cursor
= msg
; *buffer
->cursor
; ++buffer
->cursor
)
372 if (*buffer
->cursor
!= '%')
374 output_add_character (buffer
, *buffer
->cursor
);
378 /* We got a '%'. Let's see what happens. */
381 /* Let's handle the traditional cases. */
382 if (*buffer
->cursor
== 's')
383 output_add_string (buffer
, va_arg (buffer
->format_args
, const char *));
384 else if (*buffer
->cursor
== 'd')
385 output_add_integer (buffer
, va_arg (buffer
->format_args
, int));
386 else if (*buffer
->cursor
== '%')
387 /* It was a '%%'. Just output a '%'. */
388 output_add_character (buffer
, '%');
389 else if (lang_printer
)
390 (*lang_printer
) (buffer
);
393 /* Hmmm. The front-end failed to install a format translator
394 but called us with an unrecognized format. Sorry. */
398 output_finish (buffer
);
402 vbuild_message_string (msgid
, ap
)
408 vasprintf (&str
, msgid
, ap
);
412 /* Return a malloc'd string containing MSGID formatted a la
413 printf. The caller is reponsible for freeing the memory. */
416 build_message_string
VPARAMS ((const char *msgid
, ...))
418 #ifndef ANSI_PROTOTYPES
424 VA_START (ap
, msgid
);
426 #ifndef ANSI_PROTOTYPES
427 msgid
= va_arg (ap
, const char *);
430 str
= vbuild_message_string (msgid
, ap
);
438 /* Return a malloc'd string describing a location. The caller is
439 responsible for freeing the memory. */
442 build_location_prefix (file
, line
, warn
)
450 return build_message_string ("%s:%d: warning: ", file
, line
);
452 return build_message_string ("%s:%d: ", file
, line
);
457 return build_message_string ("%s: warning: ", progname
);
459 return build_message_string ("%s: ", progname
);
463 /* Format a MESSAGE into BUFFER. Automatically wrap lines. */
466 output_notice (buffer
, msgid
)
467 output_buffer
*buffer
;
470 char *message
= vbuild_message_string (msgid
, buffer
->format_args
);
472 output_add_string (buffer
, message
);
477 /* Format a message into BUFFER a la printf. */
480 output_printf
VPARAMS ((struct output_buffer
*buffer
, const char *msgid
, ...))
482 #ifndef ANSI_PROTOTYPES
483 struct output_buffer
*buffer
;
488 VA_START (ap
, msgid
);
490 #ifndef ANSI_PROTOTYPES
491 buffer
= va_arg (ap
, struct output_buffer
*);
492 msgid
= va_arg (ap
, const char *);
495 va_copy (buffer
->format_args
, ap
);
496 output_notice (buffer
, msgid
);
497 va_end (buffer
->format_args
);
501 /* Format a MESSAGE into FILE. Do line wrapping, starting new lines
505 line_wrapper_printf
VPARAMS ((FILE *file
, const char *msgid
, ...))
507 #ifndef ANSI_PROTOTYPES
511 output_buffer buffer
;
513 init_output_buffer (&buffer
, NULL
, output_maximum_width
);
514 VA_START (buffer
.format_args
, msgid
);
516 #ifndef ANSI_PROTOTYPES
517 file
= va_arg (buffer
.format_args
, FILE *);
518 msgid
= va_arg (buffer
.format_args
, const char *);
521 output_notice (&buffer
, msgid
);
522 output_flush_on (&buffer
, file
);
524 va_end (buffer
.format_args
);
529 vline_wrapper_message_with_location (file
, line
, warn
, msgid
, ap
)
536 output_buffer buffer
;
538 init_output_buffer (&buffer
, build_location_prefix (file
, line
, warn
),
539 output_maximum_width
);
540 va_copy (buffer
.format_args
, ap
);
541 output_notice (&buffer
, msgid
);
542 output_flush_on (&buffer
, stderr
);
544 free (output_get_prefix (&buffer
));
545 fputc ('\n', stderr
);
549 /* Print the message MSGID in FILE. */
552 vnotice (file
, msgid
, ap
)
557 vfprintf (file
, _(msgid
), ap
);
560 /* Print MSGID on stderr. */
563 notice
VPARAMS ((const char *msgid
, ...))
565 #ifndef ANSI_PROTOTYPES
570 VA_START (ap
, msgid
);
572 #ifndef ANSI_PROTOTYPES
573 msgid
= va_arg (ap
, char *);
576 vnotice (stderr
, msgid
, ap
);
580 /* Report FILE and LINE (or program name), and optionally just WARN. */
583 report_file_and_line (file
, line
, warn
)
589 fprintf (stderr
, "%s:%d: ", file
, line
);
591 fprintf (stderr
, "%s: ", progname
);
594 notice ("warning: ");
597 /* Print a message relevant to line LINE of file FILE. */
600 v_message_with_file_and_line (file
, line
, warn
, msgid
, ap
)
607 report_file_and_line (file
, line
, warn
);
608 vnotice (stderr
, msgid
, ap
);
609 fputc ('\n', stderr
);
612 /* Print a message relevant to the given DECL. */
615 v_message_with_decl (decl
, warn
, msgid
, ap
)
622 output_buffer buffer
;
624 if (doing_line_wrapping ())
627 (&buffer
, build_location_prefix
628 (DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
), warn
),
629 output_maximum_width
);
632 report_file_and_line (DECL_SOURCE_FILE (decl
),
633 DECL_SOURCE_LINE (decl
), warn
);
635 /* Do magic to get around lack of varargs support for insertion
636 of arguments into existing list. We know that the decl is first;
637 we ass_u_me that it will be printed with "%s". */
639 for (p
= _(msgid
); *p
; ++p
)
645 else if (*(p
+ 1) != 's')
652 if (p
> _(msgid
)) /* Print the left-hand substring. */
654 if (doing_line_wrapping ())
655 output_printf (&buffer
, "%.*s", (int)(p
- _(msgid
)), _(msgid
));
657 fprintf (stderr
, "%.*s", (int)(p
- _(msgid
)), _(msgid
));
660 if (*p
== '%') /* Print the name. */
662 const char *n
= (DECL_NAME (decl
)
663 ? (*decl_printable_name
) (decl
, 2)
665 if (doing_line_wrapping ())
666 output_add_string (&buffer
, n
);
672 if (ISALPHA (*(p
- 1) & 0xFF))
677 if (*p
) /* Print the rest of the message. */
679 if (doing_line_wrapping ())
681 va_copy (buffer
.format_args
, ap
);
682 output_notice (&buffer
, p
);
683 va_copy (ap
, buffer
.format_args
);
686 vfprintf (stderr
, p
, ap
);
689 if (doing_line_wrapping())
691 output_flush_on (&buffer
, stderr
);
692 free (output_get_prefix (&buffer
));
695 fputc ('\n', stderr
);
698 /* Figure file and line of the given INSN. */
701 file_and_line_for_asm (insn
, pfile
, pline
)
706 rtx body
= PATTERN (insn
);
709 /* Find the (or one of the) ASM_OPERANDS in the insn. */
710 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
711 asmop
= SET_SRC (body
);
712 else if (GET_CODE (body
) == ASM_OPERANDS
)
714 else if (GET_CODE (body
) == PARALLEL
715 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
716 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
717 else if (GET_CODE (body
) == PARALLEL
718 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
719 asmop
= XVECEXP (body
, 0, 0);
725 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
726 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
730 *pfile
= input_filename
;
735 /* Report an error at line LINE of file FILE. */
738 v_error_with_file_and_line (file
, line
, msgid
, ap
)
745 report_error_function (file
);
746 if (doing_line_wrapping ())
747 vline_wrapper_message_with_location (file
, line
, 0, msgid
, ap
);
749 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
752 /* Report an error at the declaration DECL.
753 MSGID is a format string which uses %s to substitute the declaration
754 name; subsequent substitutions are a la printf. */
757 v_error_with_decl (decl
, msgid
, ap
)
763 report_error_function (DECL_SOURCE_FILE (decl
));
764 v_message_with_decl (decl
, 0, msgid
, ap
);
768 /* Report an error at the line number of the insn INSN.
769 This is used only when INSN is an `asm' with operands,
770 and each ASM_OPERANDS records its own source file and line. */
773 v_error_for_asm (insn
, msgid
, ap
)
782 file_and_line_for_asm (insn
, &file
, &line
);
783 report_error_function (file
);
784 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
788 /* Report an error at the current line number. */
795 v_error_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
799 /* Report a fatal error at the current line number. Allow a front end to
800 intercept the message. */
802 static void (*fatal_function
) PARAMS ((const char *, va_list));
809 if (fatal_function
!= 0)
810 (*fatal_function
) (_(msgid
), ap
);
813 exit (FATAL_EXIT_CODE
);
816 /* Report a warning at line LINE of file FILE. */
819 v_warning_with_file_and_line (file
, line
, msgid
, ap
)
827 report_error_function (file
);
828 if (doing_line_wrapping ())
829 vline_wrapper_message_with_location (file
, line
, 1, msgid
, ap
);
831 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
836 /* Report a warning at the declaration DECL.
837 MSGID is a format string which uses %s to substitute the declaration
838 name; subsequent substitutions are a la printf. */
841 v_warning_with_decl (decl
, msgid
, ap
)
848 report_error_function (DECL_SOURCE_FILE (decl
));
849 v_message_with_decl (decl
, 1, msgid
, ap
);
854 /* Report a warning at the line number of the insn INSN.
855 This is used only when INSN is an `asm' with operands,
856 and each ASM_OPERANDS records its own source file and line. */
859 v_warning_for_asm (insn
, msgid
, ap
)
869 file_and_line_for_asm (insn
, &file
, &line
);
870 report_error_function (file
);
871 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
876 /* Report a warning at the current line number. */
883 v_warning_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
886 /* These functions issue either warnings or errors depending on
894 if (flag_pedantic_errors
)
897 vwarning (msgid
, ap
);
902 v_pedwarn_with_decl (decl
, msgid
, ap
)
907 /* We don't want -pedantic-errors to cause the compilation to fail from
908 "errors" in system header files. Sometimes fixincludes can't fix what's
909 broken (eg: unsigned char bitfields - fixing it may change the alignment
910 which will cause programs to mysteriously fail because the C library
911 or kernel uses the original layout). There's no point in issuing a
912 warning either, it's just unnecessary noise. */
914 if (! DECL_IN_SYSTEM_HEADER (decl
))
916 if (flag_pedantic_errors
)
917 v_error_with_decl (decl
, msgid
, ap
);
919 v_warning_with_decl (decl
, msgid
, ap
);
925 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
)
931 if (flag_pedantic_errors
)
932 v_error_with_file_and_line (file
, line
, msgid
, ap
);
934 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
938 /* Apologize for not implementing some feature. */
947 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
949 fprintf (stderr
, "%s: ", progname
);
950 notice ("sorry, not implemented: ");
951 vnotice (stderr
, msgid
, ap
);
952 fputc ('\n', stderr
);
956 /* Count an error or warning. Return 1 if the message should be printed. */
959 count_error (warningp
)
962 if (warningp
&& inhibit_warnings
)
965 if (warningp
&& !warnings_are_errors
)
969 static int warning_message
= 0;
971 if (warningp
&& !warning_message
)
973 notice ("%s: warnings being treated as errors\n", progname
);
982 /* Print a diagnistic MSGID on FILE. */
984 fnotice
VPARAMS ((FILE *file
, const char *msgid
, ...))
986 #ifndef ANSI_PROTOTYPES
992 VA_START (ap
, msgid
);
994 #ifndef ANSI_PROTOTYPES
995 file
= va_arg (ap
, FILE *);
996 msgid
= va_arg (ap
, const char *);
999 vnotice (file
, msgid
, ap
);
1004 /* Print a fatal error message. NAME is the text.
1005 Also include a system error message based on `errno'. */
1008 pfatal_with_name (name
)
1011 fprintf (stderr
, "%s: ", progname
);
1013 exit (FATAL_EXIT_CODE
);
1017 fatal_io_error (name
)
1020 notice ("%s: %s: I/O error\n", progname
, name
);
1021 exit (FATAL_EXIT_CODE
);
1024 /* Issue a pedantic warning MSGID. */
1026 pedwarn
VPARAMS ((const char *msgid
, ...))
1028 #ifndef ANSI_PROTOTYPES
1033 VA_START (ap
, msgid
);
1035 #ifndef ANSI_PROTOTYPES
1036 msgid
= va_arg (ap
, const char *);
1039 vpedwarn (msgid
, ap
);
1043 /* Issue a pedantic waring about DECL. */
1045 pedwarn_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1047 #ifndef ANSI_PROTOTYPES
1053 VA_START (ap
, msgid
);
1055 #ifndef ANSI_PROTOTYPES
1056 decl
= va_arg (ap
, tree
);
1057 msgid
= va_arg (ap
, const char *);
1060 v_pedwarn_with_decl (decl
, msgid
, ap
);
1064 /* Same as above but within the context FILE and LINE. */
1066 pedwarn_with_file_and_line
VPARAMS ((const char *file
, int line
,
1067 const char *msgid
, ...))
1069 #ifndef ANSI_PROTOTYPES
1076 VA_START (ap
, msgid
);
1078 #ifndef ANSI_PROTOTYPES
1079 file
= va_arg (ap
, const char *);
1080 line
= va_arg (ap
, int);
1081 msgid
= va_arg (ap
, const char *);
1084 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
);
1088 /* Just apologize with MSGID. */
1090 sorry
VPARAMS ((const char *msgid
, ...))
1092 #ifndef ANSI_PROTOTYPES
1097 VA_START (ap
, msgid
);
1099 #ifndef ANSI_PROTOTYPES
1100 msgid
= va_arg (ap
, const char *);
1107 /* Called when the start of a function definition is parsed,
1108 this function prints on stderr the name of the function. */
1111 announce_function (decl
)
1116 if (rtl_dump_and_exit
)
1117 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1120 if (doing_line_wrapping ())
1122 (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1124 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1127 need_error_newline
= 1;
1128 last_error_function
= current_function_decl
;
1132 /* The default function to print out name of current function that caused
1136 default_print_error_function (file
)
1139 if (last_error_function
!= current_function_decl
)
1141 char *prefix
= NULL
;
1142 output_buffer buffer
;
1145 prefix
= build_message_string ("%s: ", file
);
1147 if (doing_line_wrapping ())
1148 init_output_buffer (&buffer
, prefix
, output_maximum_width
);
1152 fprintf (stderr
, "%s: ", file
);
1155 if (current_function_decl
== NULL
)
1157 if (doing_line_wrapping ())
1158 output_printf (&buffer
, "At top level:\n");
1160 notice ("At top level:\n");
1164 if (TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
1166 if (doing_line_wrapping ())
1168 (&buffer
, "In method `%s':\n",
1169 (*decl_printable_name
) (current_function_decl
, 2));
1171 notice ("In method `%s':\n",
1172 (*decl_printable_name
) (current_function_decl
, 2));
1176 if (doing_line_wrapping ())
1178 (&buffer
, "In function `%s':\n",
1179 (*decl_printable_name
) (current_function_decl
, 2));
1181 notice ("In function `%s':\n",
1182 (*decl_printable_name
) (current_function_decl
, 2));
1186 last_error_function
= current_function_decl
;
1188 if (doing_line_wrapping ())
1189 output_flush_on (&buffer
, stderr
);
1191 free ((char*) prefix
);
1195 /* Prints out, if necessary, the name of the current function
1196 that caused an error. Called from all error and warning functions.
1197 We ignore the FILE parameter, as it cannot be relied upon. */
1200 report_error_function (file
)
1201 const char *file ATTRIBUTE_UNUSED
;
1203 struct file_stack
*p
;
1205 if (need_error_newline
)
1207 fprintf (stderr
, "\n");
1208 need_error_newline
= 0;
1211 if (input_file_stack
&& input_file_stack
->next
!= 0
1212 && input_file_stack_tick
!= last_error_tick
)
1214 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1215 if (p
== input_file_stack
->next
)
1216 notice ("In file included from %s:%d", p
->name
, p
->line
);
1218 notice (",\n from %s:%d", p
->name
, p
->line
);
1219 fprintf (stderr
, ":\n");
1220 last_error_tick
= input_file_stack_tick
;
1223 (*print_error_function
) (input_filename
);
1227 error_with_file_and_line
VPARAMS ((const char *file
, int line
,
1228 const char *msgid
, ...))
1230 #ifndef ANSI_PROTOTYPES
1237 VA_START (ap
, msgid
);
1239 #ifndef ANSI_PROTOTYPES
1240 file
= va_arg (ap
, const char *);
1241 line
= va_arg (ap
, int);
1242 msgid
= va_arg (ap
, const char *);
1245 v_error_with_file_and_line (file
, line
, msgid
, ap
);
1250 error_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1252 #ifndef ANSI_PROTOTYPES
1258 VA_START (ap
, msgid
);
1260 #ifndef ANSI_PROTOTYPES
1261 decl
= va_arg (ap
, tree
);
1262 msgid
= va_arg (ap
, const char *);
1265 v_error_with_decl (decl
, msgid
, ap
);
1270 error_for_asm
VPARAMS ((rtx insn
, const char *msgid
, ...))
1272 #ifndef ANSI_PROTOTYPES
1278 VA_START (ap
, msgid
);
1280 #ifndef ANSI_PROTOTYPES
1281 insn
= va_arg (ap
, rtx
);
1282 msgid
= va_arg (ap
, const char *);
1285 v_error_for_asm (insn
, msgid
, ap
);
1290 error
VPARAMS ((const char *msgid
, ...))
1292 #ifndef ANSI_PROTOTYPES
1297 VA_START (ap
, msgid
);
1299 #ifndef ANSI_PROTOTYPES
1300 msgid
= va_arg (ap
, const char *);
1307 /* Set the function to call when a fatal error occurs. */
1310 set_fatal_function (f
)
1311 void (*f
) PARAMS ((const char *, va_list));
1317 fatal
VPARAMS ((const char *msgid
, ...))
1319 #ifndef ANSI_PROTOTYPES
1324 VA_START (ap
, msgid
);
1326 #ifndef ANSI_PROTOTYPES
1327 msgid
= va_arg (ap
, const char *);
1335 _fatal_insn (msgid
, insn
, file
, line
, function
)
1340 const char *function
;
1342 error ("%s", msgid
);
1344 fancy_abort (file
, line
, function
);
1348 _fatal_insn_not_found (insn
, file
, line
, function
)
1352 const char *function
;
1354 if (INSN_CODE (insn
) < 0)
1355 _fatal_insn ("Unrecognizable insn:", insn
, file
, line
, function
);
1357 _fatal_insn ("Insn does not satisfy its constraints:",
1358 insn
, file
, line
, function
);
1362 warning_with_file_and_line
VPARAMS ((const char *file
, int line
,
1363 const char *msgid
, ...))
1365 #ifndef ANSI_PROTOTYPES
1372 VA_START (ap
, msgid
);
1374 #ifndef ANSI_PROTOTYPES
1375 file
= va_arg (ap
, const char *);
1376 line
= va_arg (ap
, int);
1377 msgid
= va_arg (ap
, const char *);
1380 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
1385 warning_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1387 #ifndef ANSI_PROTOTYPES
1393 VA_START (ap
, msgid
);
1395 #ifndef ANSI_PROTOTYPES
1396 decl
= va_arg (ap
, tree
);
1397 msgid
= va_arg (ap
, const char *);
1400 v_warning_with_decl (decl
, msgid
, ap
);
1405 warning_for_asm
VPARAMS ((rtx insn
, const char *msgid
, ...))
1407 #ifndef ANSI_PROTOTYPES
1413 VA_START (ap
, msgid
);
1415 #ifndef ANSI_PROTOTYPES
1416 insn
= va_arg (ap
, rtx
);
1417 msgid
= va_arg (ap
, const char *);
1420 v_warning_for_asm (insn
, msgid
, ap
);
1425 warning
VPARAMS ((const char *msgid
, ...))
1427 #ifndef ANSI_PROTOTYPES
1432 VA_START (ap
, msgid
);
1434 #ifndef ANSI_PROTOTYPES
1435 msgid
= va_arg (ap
, const char *);
1438 vwarning (msgid
, ap
);