#include "config.h"
#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
#include "cpplib.h"
#include "cpphash.h"
#include "intl.h"
-static void print_location PARAMS ((cpp_reader *, unsigned int, unsigned int));
+static void print_location (cpp_reader *, unsigned int, unsigned int);
/* Print the logical file location (LINE, COL) in preparation for a
diagnostic. Outputs the #include chain if it has changed. A line
of zero suppresses the include stack, and outputs the program name
instead. */
static void
-print_location (pfile, line, col)
- cpp_reader *pfile;
- unsigned int line, col;
+print_location (cpp_reader *pfile, unsigned int line, unsigned int col)
{
if (!pfile->buffer || line == 0)
fprintf (stderr, "%s: ", progname);
the correct place by default. Returns 0 if the error has been
suppressed. */
int
-_cpp_begin_message (pfile, code, line, column)
- cpp_reader *pfile;
- int code;
- unsigned int line, column;
+_cpp_begin_message (cpp_reader *pfile, int code, unsigned int line,
+ unsigned int column)
{
int level = DL_EXTRACT (code);
{
if (CPP_OPTION (pfile, inhibit_errors))
return 0;
- if (pfile->errors < CPP_FATAL_LIMIT)
- pfile->errors++;
+ level = DL_ERROR;
+ pfile->errors++;
}
else if (CPP_OPTION (pfile, inhibit_warnings))
return 0;
break;
-
+
case DL_ERROR:
if (CPP_OPTION (pfile, inhibit_errors))
return 0;
- if (pfile->errors < CPP_FATAL_LIMIT)
- pfile->errors++;
- break;
-
- /* Fatal errors cannot be inhibited. */
- case DL_FATAL:
+ /* ICEs cannot be inhibited. */
case DL_ICE:
- pfile->errors = CPP_FATAL_LIMIT;
+ pfile->errors++;
break;
}
/* Print an error at the location of the previously lexed token. */
void
-cpp_error VPARAMS ((cpp_reader * pfile, int level, const char *msgid, ...))
+cpp_error (cpp_reader * pfile, int level, const char *msgid, ...)
{
unsigned int line, column;
-
- VA_OPEN (ap, msgid);
- VA_FIXEDARG (ap, cpp_reader *, pfile);
- VA_FIXEDARG (ap, int, level);
- VA_FIXEDARG (ap, const char *, msgid);
+ va_list ap;
+
+ va_start (ap, msgid);
if (pfile->buffer)
{
- line = pfile->cur_token[-1].line;
- column = pfile->cur_token[-1].col;
+ if (CPP_OPTION (pfile, traditional))
+ {
+ if (pfile->state.in_directive)
+ line = pfile->directive_line;
+ else
+ line = pfile->line;
+ column = 0;
+ }
+ else
+ {
+ line = pfile->cur_token[-1].line;
+ column = pfile->cur_token[-1].col;
+ }
}
else
line = column = 0;
if (_cpp_begin_message (pfile, level, line, column))
v_message (msgid, ap);
- VA_CLOSE (ap);
+ va_end (ap);
}
/* Print an error at a specific location. */
void
-cpp_error_with_line VPARAMS ((cpp_reader *pfile, int level,
- unsigned int line, unsigned int column,
- const char *msgid, ...))
+cpp_error_with_line (cpp_reader *pfile, int level,
+ unsigned int line, unsigned int column,
+ const char *msgid, ...)
{
- VA_OPEN (ap, msgid);
- VA_FIXEDARG (ap, cpp_reader *, pfile);
- VA_FIXEDARG (ap, int, level);
- VA_FIXEDARG (ap, unsigned int, line);
- VA_FIXEDARG (ap, unsigned int, column);
- VA_FIXEDARG (ap, const char *, msgid);
+ va_list ap;
+
+ va_start (ap, msgid);
if (_cpp_begin_message (pfile, level, line, column))
v_message (msgid, ap);
- VA_CLOSE (ap);
+ va_end (ap);
}
void
-cpp_errno (pfile, level, msgid)
- cpp_reader *pfile;
- int level;
- const char *msgid;
+cpp_errno (cpp_reader *pfile, int level, const char *msgid)
{
if (msgid[0] == '\0')
msgid = _("stdout");