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 /* Used to control every diagnostic message formatting. Front-ends should
114 call set_message_prefixing_rule to set up their politics. */
115 static int current_prefixing_rule
= DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
;
117 /* Predicate. Return 1 if we're in automatic line wrapping mode. */
120 doing_line_wrapping ()
122 return output_maximum_width
> 0;
125 /* Set Maximum characters per line in automatic line wrapping mode. */
128 set_message_length (n
)
131 output_maximum_width
= n
;
135 set_message_prefixing_rule (rule
)
138 current_prefixing_rule
= rule
;
141 /* Returns true if BUFFER is in line-wrappind mode. */
143 output_is_line_wrapping (buffer
)
144 output_buffer
*buffer
;
146 return buffer
->ideal_maximum_length
> 0;
149 /* Return BUFFER's prefix. */
151 output_get_prefix (buffer
)
152 const output_buffer
*buffer
;
154 return buffer
->prefix
;
157 /* Subroutine of output_set_maximum_length. Set up BUFFER's
158 internal maximum characters per line. */
160 set_real_maximum_length (buffer
)
161 output_buffer
*buffer
;
163 /* If we're told not to wrap lines then do the obvious thing. */
164 if (! output_is_line_wrapping (buffer
))
165 buffer
->maximum_length
= buffer
->ideal_maximum_length
;
168 int prefix_length
= buffer
->prefix
? strlen (buffer
->prefix
) : 0;
169 /* If the prefix is ridiculously too long, output at least
171 if (buffer
->ideal_maximum_length
- prefix_length
< 32)
172 buffer
->maximum_length
= buffer
->ideal_maximum_length
+ 32;
174 buffer
->maximum_length
= buffer
->ideal_maximum_length
;
178 /* Sets the number of maximum characters per line BUFFER can output
179 in line-wrapping mode. A LENGTH value 0 suppresses line-wrapping. */
181 output_set_maximum_length (buffer
, length
)
182 output_buffer
*buffer
;
185 buffer
->ideal_maximum_length
= length
;
186 set_real_maximum_length (buffer
);
189 /* Sets BUFFER's PREFIX. */
191 output_set_prefix (buffer
, prefix
)
192 output_buffer
*buffer
;
195 buffer
->prefix
= prefix
;
196 set_real_maximum_length (buffer
);
197 buffer
->emitted_prefix_p
= 0;
200 /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
201 characters per line. */
203 init_output_buffer (buffer
, prefix
, maximum_length
)
204 output_buffer
*buffer
;
208 obstack_init (&buffer
->obstack
);
209 buffer
->ideal_maximum_length
= maximum_length
;
210 buffer
->line_length
= 0;
211 output_set_prefix (buffer
, prefix
);
212 buffer
->emitted_prefix_p
= 0;
213 buffer
->prefixing_rule
= current_prefixing_rule
;
215 buffer
->cursor
= NULL
;
218 /* Reinitialize BUFFER. */
220 output_clear (buffer
)
221 output_buffer
*buffer
;
223 obstack_free (&buffer
->obstack
, obstack_base (&buffer
->obstack
));
224 buffer
->line_length
= 0;
225 buffer
->cursor
= NULL
;
228 /* Finishes to construct a NULL-terminated character string representing
229 the BUFFERed message. */
231 output_finish (buffer
)
232 output_buffer
*buffer
;
234 obstack_1grow (&buffer
->obstack
, '\0');
235 return (const char *) obstack_finish (&buffer
->obstack
);
238 /* Return the amount of characters BUFFER can accept to
241 output_space_left (buffer
)
242 const output_buffer
*buffer
;
244 return buffer
->maximum_length
- buffer
->line_length
;
247 /* Write out BUFFER's prefix. */
249 output_emit_prefix (buffer
)
250 output_buffer
*buffer
;
254 switch (buffer
->prefixing_rule
)
257 case DIAGNOSTICS_SHOW_PREFIX_NEVER
:
260 case DIAGNOSTICS_SHOW_PREFIX_ONCE
:
261 if (buffer
->emitted_prefix_p
)
264 buffer
->emitted_prefix_p
= 1;
267 case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE
:
268 buffer
->line_length
+= strlen (buffer
->prefix
);
270 (&buffer
->obstack
, buffer
->prefix
, buffer
->line_length
);
276 /* Have BUFFER start a new line. */
278 output_add_newline (buffer
)
279 output_buffer
*buffer
;
281 obstack_1grow (&buffer
->obstack
, '\n');
282 buffer
->line_length
= 0;
285 /* Appends a character to BUFFER. */
287 output_add_character (buffer
, c
)
288 output_buffer
*buffer
;
291 if (output_is_line_wrapping (buffer
) && output_space_left (buffer
) <= 0)
292 output_add_newline (buffer
);
293 obstack_1grow (&buffer
->obstack
, c
);
294 ++buffer
->line_length
;
297 /* Adds a space to BUFFER. */
299 output_add_space (buffer
)
300 output_buffer
*buffer
;
302 if (output_is_line_wrapping (buffer
) && output_space_left (buffer
) <= 0)
304 output_add_newline (buffer
);
307 obstack_1grow (&buffer
->obstack
, ' ');
308 ++buffer
->line_length
;
311 /* Add the stringified version of an integer to BUFFER. */
313 output_add_integer (buffer
, i
)
314 output_buffer
*buffer
;
317 /* This must be large enough to hold any printed integer or
318 floating-point value. */
319 static char digit_buffer
[128];
321 sprintf (digit_buffer
, HOST_WIDE_INT_PRINT_DEC
, i
);
322 output_add_string (buffer
, digit_buffer
);
325 /* Append a string deliminated by START and END to BUFFER. No wrapping is
326 done. The caller must ensure that it is safe to do so. */
329 output_append (buffer
, start
, end
)
330 output_buffer
*buffer
;
336 /* Emit prefix and skip whitespace if we're starting a new line. */
337 if (buffer
->line_length
== 0)
339 output_emit_prefix (buffer
);
340 while (start
!= end
&& *start
== ' ')
344 obstack_grow (&buffer
->obstack
, start
, n
);
345 buffer
->line_length
+= n
;
348 /* Wrap a STRing into BUFFER. */
351 output_add_string (buffer
, str
)
352 output_buffer
*buffer
;
357 if (!output_is_line_wrapping (buffer
))
358 output_append (buffer
, str
, str
+ strlen (str
));
361 while (*p
&& *p
!= ' ' && *p
!= '\n')
364 if (p
- str
< output_space_left (buffer
))
365 output_append (buffer
, str
, p
);
368 output_add_newline (buffer
);
369 output_append (buffer
, str
, p
);
372 while (*p
&& *p
== '\n')
374 output_add_newline (buffer
);
382 /* Flush the content of BUFFER onto FILE and reinitialize BUFFER. */
385 output_flush_on (buffer
, file
)
386 output_buffer
*buffer
;
389 const char *text
= output_finish (buffer
);
391 output_clear (buffer
);
394 /* Format MESSAGE into BUFFER. */
396 output_format (buffer
, msg
)
397 output_buffer
*buffer
;
400 for (buffer
->cursor
= msg
; *buffer
->cursor
; ++buffer
->cursor
)
403 if (*buffer
->cursor
!= '%')
405 output_add_character (buffer
, *buffer
->cursor
);
409 /* We got a '%'. Let's see what happens. */
412 /* Let's handle the traditional cases. */
413 if (*buffer
->cursor
== 's')
414 output_add_string (buffer
, va_arg (buffer
->format_args
, const char *));
415 else if (*buffer
->cursor
== 'd')
416 output_add_integer (buffer
, va_arg (buffer
->format_args
, int));
417 else if (*buffer
->cursor
== '%')
418 /* It was a '%%'. Just output a '%'. */
419 output_add_character (buffer
, '%');
420 else if (lang_printer
)
421 (*lang_printer
) (buffer
);
424 /* Hmmm. The front-end failed to install a format translator
425 but called us with an unrecognized format. Sorry. */
429 output_finish (buffer
);
433 vbuild_message_string (msgid
, ap
)
439 vasprintf (&str
, msgid
, ap
);
443 /* Return a malloc'd string containing MSGID formatted a la
444 printf. The caller is reponsible for freeing the memory. */
447 build_message_string
VPARAMS ((const char *msgid
, ...))
449 #ifndef ANSI_PROTOTYPES
455 VA_START (ap
, msgid
);
457 #ifndef ANSI_PROTOTYPES
458 msgid
= va_arg (ap
, const char *);
461 str
= vbuild_message_string (msgid
, ap
);
469 /* Return a malloc'd string describing a location. The caller is
470 responsible for freeing the memory. */
473 build_location_prefix (file
, line
, warn
)
481 return build_message_string ("%s:%d: warning: ", file
, line
);
483 return build_message_string ("%s:%d: ", file
, line
);
488 return build_message_string ("%s: warning: ", progname
);
490 return build_message_string ("%s: ", progname
);
494 /* Format a MESSAGE into BUFFER. Automatically wrap lines. */
497 output_notice (buffer
, msgid
)
498 output_buffer
*buffer
;
501 char *message
= vbuild_message_string (msgid
, buffer
->format_args
);
503 output_add_string (buffer
, message
);
508 /* Format a message into BUFFER a la printf. */
511 output_printf
VPARAMS ((struct output_buffer
*buffer
, const char *msgid
, ...))
513 #ifndef ANSI_PROTOTYPES
514 struct output_buffer
*buffer
;
519 VA_START (ap
, msgid
);
521 #ifndef ANSI_PROTOTYPES
522 buffer
= va_arg (ap
, struct output_buffer
*);
523 msgid
= va_arg (ap
, const char *);
526 va_copy (buffer
->format_args
, ap
);
527 output_notice (buffer
, msgid
);
528 va_end (buffer
->format_args
);
532 /* Format a MESSAGE into FILE. Do line wrapping, starting new lines
536 line_wrapper_printf
VPARAMS ((FILE *file
, const char *msgid
, ...))
538 #ifndef ANSI_PROTOTYPES
542 output_buffer buffer
;
544 init_output_buffer (&buffer
, NULL
, output_maximum_width
);
545 VA_START (buffer
.format_args
, msgid
);
547 #ifndef ANSI_PROTOTYPES
548 file
= va_arg (buffer
.format_args
, FILE *);
549 msgid
= va_arg (buffer
.format_args
, const char *);
552 output_notice (&buffer
, msgid
);
553 output_flush_on (&buffer
, file
);
555 va_end (buffer
.format_args
);
560 vline_wrapper_message_with_location (file
, line
, warn
, msgid
, ap
)
567 output_buffer buffer
;
569 init_output_buffer (&buffer
, build_location_prefix (file
, line
, warn
),
570 output_maximum_width
);
571 va_copy (buffer
.format_args
, ap
);
572 output_notice (&buffer
, msgid
);
573 output_flush_on (&buffer
, stderr
);
575 free (output_get_prefix (&buffer
));
576 fputc ('\n', stderr
);
580 /* Print the message MSGID in FILE. */
583 vnotice (file
, msgid
, ap
)
588 vfprintf (file
, _(msgid
), ap
);
591 /* Print MSGID on stderr. */
594 notice
VPARAMS ((const char *msgid
, ...))
596 #ifndef ANSI_PROTOTYPES
601 VA_START (ap
, msgid
);
603 #ifndef ANSI_PROTOTYPES
604 msgid
= va_arg (ap
, char *);
607 vnotice (stderr
, msgid
, ap
);
611 /* Report FILE and LINE (or program name), and optionally just WARN. */
614 report_file_and_line (file
, line
, warn
)
620 fprintf (stderr
, "%s:%d: ", file
, line
);
622 fprintf (stderr
, "%s: ", progname
);
625 notice ("warning: ");
628 /* Print a message relevant to line LINE of file FILE. */
631 v_message_with_file_and_line (file
, line
, warn
, msgid
, ap
)
638 report_file_and_line (file
, line
, warn
);
639 vnotice (stderr
, msgid
, ap
);
640 fputc ('\n', stderr
);
643 /* Print a message relevant to the given DECL. */
646 v_message_with_decl (decl
, warn
, msgid
, ap
)
653 output_buffer buffer
;
655 if (doing_line_wrapping ())
658 (&buffer
, build_location_prefix
659 (DECL_SOURCE_FILE (decl
), DECL_SOURCE_LINE (decl
), warn
),
660 output_maximum_width
);
663 report_file_and_line (DECL_SOURCE_FILE (decl
),
664 DECL_SOURCE_LINE (decl
), warn
);
666 /* Do magic to get around lack of varargs support for insertion
667 of arguments into existing list. We know that the decl is first;
668 we ass_u_me that it will be printed with "%s". */
670 for (p
= _(msgid
); *p
; ++p
)
676 else if (*(p
+ 1) != 's')
683 if (p
> _(msgid
)) /* Print the left-hand substring. */
685 if (doing_line_wrapping ())
686 output_printf (&buffer
, "%.*s", (int)(p
- _(msgid
)), _(msgid
));
688 fprintf (stderr
, "%.*s", (int)(p
- _(msgid
)), _(msgid
));
691 if (*p
== '%') /* Print the name. */
693 const char *n
= (DECL_NAME (decl
)
694 ? (*decl_printable_name
) (decl
, 2)
696 if (doing_line_wrapping ())
697 output_add_string (&buffer
, n
);
703 if (ISALPHA (*(p
- 1) & 0xFF))
708 if (*p
) /* Print the rest of the message. */
710 if (doing_line_wrapping ())
712 va_copy (buffer
.format_args
, ap
);
713 output_notice (&buffer
, p
);
714 va_copy (ap
, buffer
.format_args
);
717 vfprintf (stderr
, p
, ap
);
720 if (doing_line_wrapping())
722 output_flush_on (&buffer
, stderr
);
723 free (output_get_prefix (&buffer
));
726 fputc ('\n', stderr
);
729 /* Figure file and line of the given INSN. */
732 file_and_line_for_asm (insn
, pfile
, pline
)
737 rtx body
= PATTERN (insn
);
740 /* Find the (or one of the) ASM_OPERANDS in the insn. */
741 if (GET_CODE (body
) == SET
&& GET_CODE (SET_SRC (body
)) == ASM_OPERANDS
)
742 asmop
= SET_SRC (body
);
743 else if (GET_CODE (body
) == ASM_OPERANDS
)
745 else if (GET_CODE (body
) == PARALLEL
746 && GET_CODE (XVECEXP (body
, 0, 0)) == SET
)
747 asmop
= SET_SRC (XVECEXP (body
, 0, 0));
748 else if (GET_CODE (body
) == PARALLEL
749 && GET_CODE (XVECEXP (body
, 0, 0)) == ASM_OPERANDS
)
750 asmop
= XVECEXP (body
, 0, 0);
756 *pfile
= ASM_OPERANDS_SOURCE_FILE (asmop
);
757 *pline
= ASM_OPERANDS_SOURCE_LINE (asmop
);
761 *pfile
= input_filename
;
766 /* Report an error at line LINE of file FILE. */
769 v_error_with_file_and_line (file
, line
, msgid
, ap
)
776 report_error_function (file
);
777 if (doing_line_wrapping ())
778 vline_wrapper_message_with_location (file
, line
, 0, msgid
, ap
);
780 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
783 /* Report an error at the declaration DECL.
784 MSGID is a format string which uses %s to substitute the declaration
785 name; subsequent substitutions are a la printf. */
788 v_error_with_decl (decl
, msgid
, ap
)
794 report_error_function (DECL_SOURCE_FILE (decl
));
795 v_message_with_decl (decl
, 0, msgid
, ap
);
799 /* Report an error at the line number of the insn INSN.
800 This is used only when INSN is an `asm' with operands,
801 and each ASM_OPERANDS records its own source file and line. */
804 v_error_for_asm (insn
, msgid
, ap
)
813 file_and_line_for_asm (insn
, &file
, &line
);
814 report_error_function (file
);
815 v_message_with_file_and_line (file
, line
, 0, msgid
, ap
);
819 /* Report an error at the current line number. */
826 v_error_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
830 /* Report a fatal error at the current line number. Allow a front end to
831 intercept the message. */
833 static void (*fatal_function
) PARAMS ((const char *, va_list));
840 if (fatal_function
!= 0)
841 (*fatal_function
) (_(msgid
), ap
);
844 exit (FATAL_EXIT_CODE
);
847 /* Report a warning at line LINE of file FILE. */
850 v_warning_with_file_and_line (file
, line
, msgid
, ap
)
858 report_error_function (file
);
859 if (doing_line_wrapping ())
860 vline_wrapper_message_with_location (file
, line
, 1, msgid
, ap
);
862 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
867 /* Report a warning at the declaration DECL.
868 MSGID is a format string which uses %s to substitute the declaration
869 name; subsequent substitutions are a la printf. */
872 v_warning_with_decl (decl
, msgid
, ap
)
879 report_error_function (DECL_SOURCE_FILE (decl
));
880 v_message_with_decl (decl
, 1, msgid
, ap
);
885 /* Report a warning at the line number of the insn INSN.
886 This is used only when INSN is an `asm' with operands,
887 and each ASM_OPERANDS records its own source file and line. */
890 v_warning_for_asm (insn
, msgid
, ap
)
900 file_and_line_for_asm (insn
, &file
, &line
);
901 report_error_function (file
);
902 v_message_with_file_and_line (file
, line
, 1, msgid
, ap
);
907 /* Report a warning at the current line number. */
914 v_warning_with_file_and_line (input_filename
, lineno
, msgid
, ap
);
917 /* These functions issue either warnings or errors depending on
925 if (flag_pedantic_errors
)
928 vwarning (msgid
, ap
);
933 v_pedwarn_with_decl (decl
, msgid
, ap
)
938 /* We don't want -pedantic-errors to cause the compilation to fail from
939 "errors" in system header files. Sometimes fixincludes can't fix what's
940 broken (eg: unsigned char bitfields - fixing it may change the alignment
941 which will cause programs to mysteriously fail because the C library
942 or kernel uses the original layout). There's no point in issuing a
943 warning either, it's just unnecessary noise. */
945 if (! DECL_IN_SYSTEM_HEADER (decl
))
947 if (flag_pedantic_errors
)
948 v_error_with_decl (decl
, msgid
, ap
);
950 v_warning_with_decl (decl
, msgid
, ap
);
956 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
)
962 if (flag_pedantic_errors
)
963 v_error_with_file_and_line (file
, line
, msgid
, ap
);
965 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
969 /* Apologize for not implementing some feature. */
978 fprintf (stderr
, "%s:%d: ", input_filename
, lineno
);
980 fprintf (stderr
, "%s: ", progname
);
981 notice ("sorry, not implemented: ");
982 vnotice (stderr
, msgid
, ap
);
983 fputc ('\n', stderr
);
987 /* Count an error or warning. Return 1 if the message should be printed. */
990 count_error (warningp
)
993 if (warningp
&& inhibit_warnings
)
996 if (warningp
&& !warnings_are_errors
)
1000 static int warning_message
= 0;
1002 if (warningp
&& !warning_message
)
1004 notice ("%s: warnings being treated as errors\n", progname
);
1005 warning_message
= 1;
1013 /* Print a diagnistic MSGID on FILE. */
1015 fnotice
VPARAMS ((FILE *file
, const char *msgid
, ...))
1017 #ifndef ANSI_PROTOTYPES
1023 VA_START (ap
, msgid
);
1025 #ifndef ANSI_PROTOTYPES
1026 file
= va_arg (ap
, FILE *);
1027 msgid
= va_arg (ap
, const char *);
1030 vnotice (file
, msgid
, ap
);
1035 /* Print a fatal error message. NAME is the text.
1036 Also include a system error message based on `errno'. */
1039 pfatal_with_name (name
)
1042 fprintf (stderr
, "%s: ", progname
);
1044 exit (FATAL_EXIT_CODE
);
1048 fatal_io_error (name
)
1051 notice ("%s: %s: I/O error\n", progname
, name
);
1052 exit (FATAL_EXIT_CODE
);
1055 /* Issue a pedantic warning MSGID. */
1057 pedwarn
VPARAMS ((const char *msgid
, ...))
1059 #ifndef ANSI_PROTOTYPES
1064 VA_START (ap
, msgid
);
1066 #ifndef ANSI_PROTOTYPES
1067 msgid
= va_arg (ap
, const char *);
1070 vpedwarn (msgid
, ap
);
1074 /* Issue a pedantic waring about DECL. */
1076 pedwarn_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1078 #ifndef ANSI_PROTOTYPES
1084 VA_START (ap
, msgid
);
1086 #ifndef ANSI_PROTOTYPES
1087 decl
= va_arg (ap
, tree
);
1088 msgid
= va_arg (ap
, const char *);
1091 v_pedwarn_with_decl (decl
, msgid
, ap
);
1095 /* Same as above but within the context FILE and LINE. */
1097 pedwarn_with_file_and_line
VPARAMS ((const char *file
, int line
,
1098 const char *msgid
, ...))
1100 #ifndef ANSI_PROTOTYPES
1107 VA_START (ap
, msgid
);
1109 #ifndef ANSI_PROTOTYPES
1110 file
= va_arg (ap
, const char *);
1111 line
= va_arg (ap
, int);
1112 msgid
= va_arg (ap
, const char *);
1115 v_pedwarn_with_file_and_line (file
, line
, msgid
, ap
);
1119 /* Just apologize with MSGID. */
1121 sorry
VPARAMS ((const char *msgid
, ...))
1123 #ifndef ANSI_PROTOTYPES
1128 VA_START (ap
, msgid
);
1130 #ifndef ANSI_PROTOTYPES
1131 msgid
= va_arg (ap
, const char *);
1138 /* Called when the start of a function definition is parsed,
1139 this function prints on stderr the name of the function. */
1142 announce_function (decl
)
1147 if (rtl_dump_and_exit
)
1148 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
1151 if (doing_line_wrapping ())
1153 (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1155 fprintf (stderr
, " %s", (*decl_printable_name
) (decl
, 2));
1158 need_error_newline
= 1;
1159 last_error_function
= current_function_decl
;
1163 /* The default function to print out name of current function that caused
1167 default_print_error_function (file
)
1170 if (last_error_function
!= current_function_decl
)
1172 char *prefix
= NULL
;
1173 output_buffer buffer
;
1176 prefix
= build_message_string ("%s: ", file
);
1178 if (doing_line_wrapping ())
1179 init_output_buffer (&buffer
, prefix
, output_maximum_width
);
1183 fprintf (stderr
, "%s: ", file
);
1186 if (current_function_decl
== NULL
)
1188 if (doing_line_wrapping ())
1189 output_printf (&buffer
, "At top level:\n");
1191 notice ("At top level:\n");
1195 if (TREE_CODE (TREE_TYPE (current_function_decl
)) == METHOD_TYPE
)
1197 if (doing_line_wrapping ())
1199 (&buffer
, "In method `%s':\n",
1200 (*decl_printable_name
) (current_function_decl
, 2));
1202 notice ("In method `%s':\n",
1203 (*decl_printable_name
) (current_function_decl
, 2));
1207 if (doing_line_wrapping ())
1209 (&buffer
, "In function `%s':\n",
1210 (*decl_printable_name
) (current_function_decl
, 2));
1212 notice ("In function `%s':\n",
1213 (*decl_printable_name
) (current_function_decl
, 2));
1217 last_error_function
= current_function_decl
;
1219 if (doing_line_wrapping ())
1220 output_flush_on (&buffer
, stderr
);
1222 free ((char*) prefix
);
1226 /* Prints out, if necessary, the name of the current function
1227 that caused an error. Called from all error and warning functions.
1228 We ignore the FILE parameter, as it cannot be relied upon. */
1231 report_error_function (file
)
1232 const char *file ATTRIBUTE_UNUSED
;
1234 struct file_stack
*p
;
1236 if (need_error_newline
)
1238 fprintf (stderr
, "\n");
1239 need_error_newline
= 0;
1242 if (input_file_stack
&& input_file_stack
->next
!= 0
1243 && input_file_stack_tick
!= last_error_tick
)
1245 for (p
= input_file_stack
->next
; p
; p
= p
->next
)
1246 if (p
== input_file_stack
->next
)
1247 notice ("In file included from %s:%d", p
->name
, p
->line
);
1249 notice (",\n from %s:%d", p
->name
, p
->line
);
1250 fprintf (stderr
, ":\n");
1251 last_error_tick
= input_file_stack_tick
;
1254 (*print_error_function
) (input_filename
);
1258 error_with_file_and_line
VPARAMS ((const char *file
, int line
,
1259 const char *msgid
, ...))
1261 #ifndef ANSI_PROTOTYPES
1268 VA_START (ap
, msgid
);
1270 #ifndef ANSI_PROTOTYPES
1271 file
= va_arg (ap
, const char *);
1272 line
= va_arg (ap
, int);
1273 msgid
= va_arg (ap
, const char *);
1276 v_error_with_file_and_line (file
, line
, msgid
, ap
);
1281 error_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1283 #ifndef ANSI_PROTOTYPES
1289 VA_START (ap
, msgid
);
1291 #ifndef ANSI_PROTOTYPES
1292 decl
= va_arg (ap
, tree
);
1293 msgid
= va_arg (ap
, const char *);
1296 v_error_with_decl (decl
, msgid
, ap
);
1301 error_for_asm
VPARAMS ((rtx insn
, const char *msgid
, ...))
1303 #ifndef ANSI_PROTOTYPES
1309 VA_START (ap
, msgid
);
1311 #ifndef ANSI_PROTOTYPES
1312 insn
= va_arg (ap
, rtx
);
1313 msgid
= va_arg (ap
, const char *);
1316 v_error_for_asm (insn
, msgid
, ap
);
1321 error
VPARAMS ((const char *msgid
, ...))
1323 #ifndef ANSI_PROTOTYPES
1328 VA_START (ap
, msgid
);
1330 #ifndef ANSI_PROTOTYPES
1331 msgid
= va_arg (ap
, const char *);
1338 /* Set the function to call when a fatal error occurs. */
1341 set_fatal_function (f
)
1342 void (*f
) PARAMS ((const char *, va_list));
1348 fatal
VPARAMS ((const char *msgid
, ...))
1350 #ifndef ANSI_PROTOTYPES
1355 VA_START (ap
, msgid
);
1357 #ifndef ANSI_PROTOTYPES
1358 msgid
= va_arg (ap
, const char *);
1366 _fatal_insn (msgid
, insn
, file
, line
, function
)
1371 const char *function
;
1373 error ("%s", msgid
);
1375 fancy_abort (file
, line
, function
);
1379 _fatal_insn_not_found (insn
, file
, line
, function
)
1383 const char *function
;
1385 if (INSN_CODE (insn
) < 0)
1386 _fatal_insn ("Unrecognizable insn:", insn
, file
, line
, function
);
1388 _fatal_insn ("Insn does not satisfy its constraints:",
1389 insn
, file
, line
, function
);
1393 warning_with_file_and_line
VPARAMS ((const char *file
, int line
,
1394 const char *msgid
, ...))
1396 #ifndef ANSI_PROTOTYPES
1403 VA_START (ap
, msgid
);
1405 #ifndef ANSI_PROTOTYPES
1406 file
= va_arg (ap
, const char *);
1407 line
= va_arg (ap
, int);
1408 msgid
= va_arg (ap
, const char *);
1411 v_warning_with_file_and_line (file
, line
, msgid
, ap
);
1416 warning_with_decl
VPARAMS ((tree decl
, const char *msgid
, ...))
1418 #ifndef ANSI_PROTOTYPES
1424 VA_START (ap
, msgid
);
1426 #ifndef ANSI_PROTOTYPES
1427 decl
= va_arg (ap
, tree
);
1428 msgid
= va_arg (ap
, const char *);
1431 v_warning_with_decl (decl
, msgid
, ap
);
1436 warning_for_asm
VPARAMS ((rtx insn
, const char *msgid
, ...))
1438 #ifndef ANSI_PROTOTYPES
1444 VA_START (ap
, msgid
);
1446 #ifndef ANSI_PROTOTYPES
1447 insn
= va_arg (ap
, rtx
);
1448 msgid
= va_arg (ap
, const char *);
1451 v_warning_for_asm (insn
, msgid
, ap
);
1456 warning
VPARAMS ((const char *msgid
, ...))
1458 #ifndef ANSI_PROTOTYPES
1463 VA_START (ap
, msgid
);
1465 #ifndef ANSI_PROTOTYPES
1466 msgid
= va_arg (ap
, const char *);
1469 vwarning (msgid
, ap
);