if (first)
{
first = 0;
- /* N.B. The current line in each outer source file is one
- greater than the line of the #include, so we must
- subtract one to correct for that. */
+ /* The current line in each outer source file is now the
+ same as the line of the #include. */
fprintf (stderr, _("In file included from %s:%u"),
- ip->nominal_fname, CPP_BUF_LINE (ip) - 1);
+ ip->nominal_fname, CPP_BUF_LINE (ip));
}
else
/* Translators note: this message is used in conjunction
const char *filename;
unsigned int line, column;
{
- if (line == 0)
- fputs (_("<command line>: "), stderr);
+ if (filename == 0 || *filename == '\0')
+ filename = "<stdin>";
+
+ if (line == (unsigned int)-1)
+ fprintf (stderr, "%s: ", filename);
+ else if (column > 0)
+ fprintf (stderr, "%s:%u:%u: ", filename, line, column);
else
- {
- if (filename == 0 || *filename == '\0')
- filename = "<stdin>";
- if (column > 0)
- fprintf (stderr, "%s:%u:%u: ", filename, line, column);
- else
- fprintf (stderr, "%s:%u: ", filename, line);
- }
+ fprintf (stderr, "%s:%u: ", filename, line);
}
/* Set up for an error message: print the file and line, bump the error
If it returns 0, this error has been suppressed. */
int
-_cpp_begin_message (pfile, code, file, line, col)
+_cpp_begin_message (pfile, code, file, pos)
cpp_reader *pfile;
enum error_type code;
const char *file;
- unsigned int line;
- unsigned int col;
+ const cpp_lexer_pos *pos;
{
cpp_buffer *ip = CPP_BUFFER (pfile);
int is_warning = 0;
switch (code)
{
case WARNING:
+ if (CPP_IN_SYSTEM_HEADER (pfile)
+ && ! CPP_OPTION (pfile, warn_system_headers))
+ return 0;
if (! CPP_OPTION (pfile, warnings_are_errors))
{
- if (CPP_OPTION (pfile, inhibit_warnings))
+ if (CPP_OPTION (pfile, inhibit_warnings))
return 0;
is_warning = 1;
}
break;
case PEDWARN:
+ if (CPP_IN_SYSTEM_HEADER (pfile)
+ && ! CPP_OPTION (pfile, warn_system_headers))
+ return 0;
if (! CPP_OPTION (pfile, pedantic_errors))
{
- if (CPP_OPTION (pfile, inhibit_warnings))
+ if (CPP_OPTION (pfile, inhibit_warnings))
return 0;
is_warning = 1;
}
{
if (file == NULL)
file = ip->nominal_fname;
- if (line == 0)
- line = _cpp_get_line (pfile, &col);
+ if (pos == 0)
+ pos = cpp_get_line (pfile);
print_containing_files (pfile, ip);
- print_file_and_line (file, line,
- CPP_OPTION (pfile, show_column) ? col : 0);
+ print_file_and_line (file, pos->line,
+ CPP_OPTION (pfile, show_column) ? pos->col : 0);
}
else
fprintf (stderr, "%s: ", progname);
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, ICE, NULL, 0, 0))
+ if (_cpp_begin_message (pfile, ICE, NULL, 0))
v_message (msgid, ap);
va_end(ap);
}
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, FATAL, NULL, 0, 0))
+ if (_cpp_begin_message (pfile, FATAL, NULL, 0))
v_message (msgid, ap);
va_end(ap);
}
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, ERROR, NULL, 0, 0))
+ if (_cpp_begin_message (pfile, ERROR, NULL, 0))
v_message (msgid, ap);
va_end(ap);
}
const char *msgid;
#endif
va_list ap;
+ cpp_lexer_pos pos;
VA_START (ap, msgid);
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, ERROR, NULL, line, column))
+ pos.line = line;
+ pos.col = column;
+ if (_cpp_begin_message (pfile, ERROR, NULL, &pos))
v_message (msgid, ap);
va_end(ap);
}
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, WARNING, NULL, 0, 0))
+ if (_cpp_begin_message (pfile, WARNING, NULL, 0))
v_message (msgid, ap);
va_end(ap);
}
const char *msgid;
#endif
va_list ap;
+ cpp_lexer_pos pos;
VA_START (ap, msgid);
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, WARNING, NULL, line, column))
+ pos.line = line;
+ pos.col = column;
+ if (_cpp_begin_message (pfile, WARNING, NULL, &pos))
v_message (msgid, ap);
va_end(ap);
}
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, PEDWARN, NULL, 0, 0))
+ if (_cpp_begin_message (pfile, PEDWARN, NULL, 0))
v_message (msgid, ap);
va_end(ap);
}
const char *msgid;
#endif
va_list ap;
+ cpp_lexer_pos pos;
VA_START (ap, msgid);
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, PEDWARN, NULL, line, column))
+ pos.line = line;
+ pos.col = column;
+ if (_cpp_begin_message (pfile, PEDWARN, NULL, &pos))
v_message (msgid, ap);
va_end(ap);
}
const char *msgid;
#endif
va_list ap;
+ cpp_lexer_pos pos;
VA_START (ap, msgid);
msgid = va_arg (ap, const char *);
#endif
- if (_cpp_begin_message (pfile, PEDWARN, file, line, col))
+ pos.line = line;
+ pos.col = col;
+ if (_cpp_begin_message (pfile, PEDWARN, file, &pos))
v_message (msgid, ap);
va_end(ap);
}
name = "stdout";
cpp_notice (pfile, "%s: %s", name, xstrerror (errno));
}
-
-const char *
-cpp_type2name (type)
- enum cpp_ttype type;
-{
- return (const char *) _cpp_token_spellings[type].name;
-}
-