#undef FLOAT /* This is for hpux. They should change hpux. */
#undef FFS /* Some systems define this in param.h. */
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "tree.h"
#include "tm_p.h"
#include "flags.h"
#include "langhooks.h"
#include "langhooks-def.h"
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-#define output_formatted_integer(BUFFER, FORMAT, INTEGER) \
- do \
- { \
- sprintf ((BUFFER)->digit_buffer, FORMAT, INTEGER); \
- output_add_string (BUFFER, (BUFFER)->digit_buffer); \
- } \
- while (0)
-
#define output_text_length(BUFFER) (BUFFER)->line_length
#define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0)
#define line_wrap_cutoff(BUFFER) (BUFFER)->state.maximum_length
diagnostic_info *));
static void error_recursion PARAMS ((diagnostic_context *)) ATTRIBUTE_NORETURN;
+static bool text_specifies_location PARAMS ((text_info *, location_t *));
extern int rtl_dump_and_exit;
extern int warnings_are_errors;
output_buffer *buffer;
int i;
{
- output_formatted_integer (buffer, "%d", i);
+ output_formatted_scalar (buffer, "%d", i);
}
static void
output_buffer *buffer;
long int i;
{
- output_formatted_integer (buffer, "%ld", i);
+ output_formatted_scalar (buffer, "%ld", i);
}
static void
output_buffer *buffer;
unsigned int i;
{
- output_formatted_integer (buffer, "%u", i);
+ output_formatted_scalar (buffer, "%u", i);
}
static void
output_buffer *buffer;
long unsigned int i;
{
- output_formatted_integer (buffer, "%lu", i);
+ output_formatted_scalar (buffer, "%lu", i);
}
static void
output_buffer *buffer;
unsigned int i;
{
- output_formatted_integer (buffer, "%o", i);
+ output_formatted_scalar (buffer, "%o", i);
}
static void
output_buffer *buffer;
unsigned long int i;
{
- output_formatted_integer (buffer, "%lo", i);
+ output_formatted_scalar (buffer, "%lo", i);
}
static void
output_buffer *buffer;
unsigned int i;
{
- output_formatted_integer (buffer, "%x", i);
+ output_formatted_scalar (buffer, "%x", i);
}
static void
output_buffer *buffer;
unsigned long int i;
{
- output_formatted_integer (buffer, "%lx", i);
+ output_formatted_scalar (buffer, "%lx", i);
}
/* Append to BUFFER a string specified by its STARTING character
maybe_wrap_text (buffer, str, str + (str ? strlen (str) : 0));
}
+/* Append an identifier ID to BUFFER. */
+void
+output_add_identifier (buffer, id)
+ output_buffer *buffer;
+ tree id;
+{
+ output_append (buffer, IDENTIFIER_POINTER (id),
+ IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
+}
+
/* Flush the content of BUFFER onto the attached stream,
and reinitialize. */
%c: character.
%s: string.
%%: `%'.
- %*.s: a substring the length of which is specified by an integer. */
+ %*.s: a substring the length of which is specified by an integer.
+ %H: location_t. */
static void
output_format (buffer, text)
output_buffer *buffer;
output_add_character (buffer, '%');
break;
+ case 'H':
+ {
+ const location_t *locus = va_arg (*text->args_ptr, location_t *);
+ output_add_string (buffer, "file '");
+ output_add_string (buffer, locus->file);
+ output_add_string (buffer, "', line ");
+ output_decimal (buffer, locus->line);
+ }
+ break;
+
case '.':
{
int n;
return str;
}
-/* Same as diagnsotic_build_prefix, but only the source FILE is given. */
+/* Same as diagnostic_build_prefix, but only the source FILE is given. */
char *
file_name_as_prefix (f)
const char *f;
diagnostic_starter (context) = default_diagnostic_starter;
diagnostic_finalizer (context) = default_diagnostic_finalizer;
+ context->warnings_are_errors_message = warnings_are_errors;
+}
+
+/* Returns true if the next format specifier in TEXT is a format specifier
+ for a location_t. If so, update the object pointed by LOCUS to reflect
+ the specified location in *TEXT->args_ptr. */
+static bool
+text_specifies_location (text, locus)
+ text_info *text;
+ location_t *locus;
+{
+ const char *p;
+ /* Skip any leading text. */
+ for (p = text->format_spec; *p && *p != '%'; ++p)
+ ;
+
+ /* Extract the location information if any. */
+ if (*p == '%' && *++p == 'H')
+ {
+ *locus = *va_arg (*text->args_ptr, location_t *);
+ text->format_spec = p + 1;
+ return true;
+ }
+
+ return false;
}
void
{
diagnostic->message.format_spec = msgid;
diagnostic->message.args_ptr = args;
- diagnostic->location.file = file;
- diagnostic->location.line = line;
+ /* If the diagnostic message doesn't specify a location,
+ use FILE and LINE. */
+ if (!text_specifies_location (&diagnostic->message, &diagnostic->location))
+ {
+ diagnostic->location.file = file;
+ diagnostic->location.line = line;
+ }
diagnostic->kind = kind;
}
diagnostic_build_prefix (diagnostic)
diagnostic_info *diagnostic;
{
- static const char *diagnostic_kind_text[] = {
-#define DEFINE_DIAGNOSTIC_KIND(K, T) _(T),
+ static const char *const diagnostic_kind_text[] = {
+#define DEFINE_DIAGNOSTIC_KIND(K, T) (T),
#include "diagnostic.def"
#undef DEFINE_DIAGNOSTIC_KIND
"must-not-happen"
? build_message_string ("%s:%d: %s",
diagnostic->location.file,
diagnostic->location.line,
- diagnostic_kind_text[diagnostic->kind])
+ _(diagnostic_kind_text[diagnostic->kind]))
: build_message_string ("%s: %s", progname,
- diagnostic_kind_text[diagnostic->kind]);
+ _(diagnostic_kind_text[diagnostic->kind]));
}
/* Report a diagnostic MESSAGE at the declaration DECL.
if (global_dc->lock++)
error_recursion (global_dc);
- if (diagnostic_count_error (global_dc, diagnostic->kind))
+ if (diagnostic_count_diagnostic (global_dc, diagnostic->kind))
{
diagnostic_report_current_function (global_dc);
output_set_prefix
fflush (output_buffer_attached_stream (&context->buffer));
}
-/* Count an error or warning. Return true if the message should be
- printed. */
+/* Count a diagnostic. Return true if the message should be printed. */
bool
-diagnostic_count_error (context, kind)
+diagnostic_count_diagnostic (context, kind)
diagnostic_context *context;
diagnostic_t kind;
{
- if (kind == DK_WARNING && !diagnostic_report_warnings_p ())
- return false;
-
- if (kind == DK_WARNING && !warnings_are_errors)
- ++diagnostic_kind_count (context, DK_WARNING);
- else
+ switch (kind)
{
- static bool warning_message = false;
-
- if (kind == DK_WARNING && !warning_message)
- {
+ default:
+ abort();
+ break;
+
+ case DK_FATAL: case DK_ICE: case DK_SORRY:
+ case DK_ANACHRONISM: case DK_NOTE:
+ ++diagnostic_kind_count (context, kind);
+ break;
+
+ case DK_WARNING:
+ if (!diagnostic_report_warnings_p ())
+ return false;
+ else if (!warnings_are_errors)
+ {
+ ++diagnostic_kind_count (context, DK_WARNING);
+ break;
+ }
+ /* else fall through. */
+
+ case DK_ERROR:
+ if (kind == DK_WARNING && context->warnings_are_errors_message)
+ {
output_verbatim (&context->buffer,
"%s: warnings being treated as errors\n", progname);
- warning_message = true;
- }
+ context->warnings_are_errors_message = false;
+ }
++diagnostic_kind_count (context, DK_ERROR);
+ break;
}
return true;
output_set_prefix
(&global_dc->buffer, diagnostic_build_prefix (&diagnostic));
- output_printf (&global_dc->buffer, "sorry, not implemented: ");
output_format (&global_dc->buffer, &diagnostic.message);
output_flush (&global_dc->buffer);
VA_CLOSE (ap);
fnotice (stderr,
"Please submit a full bug report,\n\
with preprocessed source if appropriate.\n\
-See %s for instructions.\n", GCCBUGURL);
+See %s for instructions.\n", bug_report_url);
exit (FATAL_EXIT_CODE);
}
if (context->lock++)
error_recursion (context);
- if (diagnostic_count_error (context, diagnostic->kind))
+ if (diagnostic_count_diagnostic (context, diagnostic->kind))
{
(*diagnostic_starter (context)) (context, diagnostic);
output_format (&context->buffer, &diagnostic->message);
fnotice (stderr,
"Please submit a full bug report,\n\
with preprocessed source if appropriate.\n\
-See %s for instructions.\n", GCCBUGURL);
+See %s for instructions.\n", bug_report_url);
exit (FATAL_EXIT_CODE);
}
int line;
const char *function;
{
- internal_error ("Internal compiler error in %s, at %s:%d",
- function, trim_filename (file), line);
+ internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
}
void
}
void
+inform VPARAMS ((const char *msgid, ...))
+{
+ diagnostic_info diagnostic;
+
+ VA_OPEN (ap, msgid);
+ VA_FIXEDARG (ap, const char *, msgid);
+
+ diagnostic_set_info (&diagnostic, msgid, &ap, input_filename, lineno,
+ DK_NOTE);
+ report_diagnostic (&diagnostic);
+ VA_CLOSE (ap);
+}
+
+void
warn_deprecated_use (node)
tree node;
{