aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c222
1 files changed, 220 insertions, 2 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 78ac535..6589f80 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -4723,7 +4723,9 @@ cpp_get_token (pfile)
return CPP_COMMENT;
}
else if (CPP_TRADITIONAL (pfile))
- goto get_next;
+ {
+ return CPP_COMMENT;
+ }
else
{
#if 0
@@ -7289,6 +7291,222 @@ cpp_read_check_assertion (pfile)
CPP_ADJUST_WRITTEN (pfile, - name_length); /* pop */
return result;
}
+
+void
+cpp_print_file_and_line (pfile)
+ cpp_reader *pfile;
+{
+ cpp_buffer *ip = cpp_file_buffer (pfile);
+
+ if (ip != NULL)
+ {
+ long line, col;
+ cpp_buf_line_and_col (ip, &line, &col);
+ cpp_file_line_for_message (pfile, ip->nominal_fname,
+ line, pfile->show_column ? col : -1);
+ }
+}
+
+void
+cpp_error (pfile, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ cpp_print_containing_files (pfile);
+ cpp_print_file_and_line (pfile);
+ cpp_message (pfile, 1, msg, arg1, arg2, arg3);
+}
+
+/* Print error message but don't count it. */
+
+void
+cpp_warning (pfile, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ if (CPP_OPTIONS (pfile)->inhibit_warnings)
+ return;
+
+ if (CPP_OPTIONS (pfile)->warnings_are_errors)
+ pfile->errors++;
+
+ cpp_print_containing_files (pfile);
+ cpp_print_file_and_line (pfile);
+ cpp_message (pfile, 0, msg, arg1, arg2, arg3);
+}
+
+/* Print an error message and maybe count it. */
+
+void
+cpp_pedwarn (pfile, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ if (CPP_OPTIONS (pfile)->pedantic_errors)
+ cpp_error (pfile, msg, arg1, arg2, arg3);
+ else
+ cpp_warning (pfile, msg, arg1, arg2, arg3);
+}
+
+void
+cpp_error_with_line (pfile, line, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ int line;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ int i;
+ cpp_buffer *ip = cpp_file_buffer (pfile);
+
+ cpp_print_containing_files (pfile);
+
+ if (ip != NULL)
+ cpp_file_line_for_message (pfile, ip->nominal_fname, line, -1);
+
+ cpp_message (pfile, 1, msg, arg1, arg2, arg3);
+}
+
+void
+cpp_warning_with_line (pfile, line, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ int line;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ int i;
+ cpp_buffer *ip;
+
+ if (CPP_OPTIONS (pfile)->inhibit_warnings)
+ return;
+
+ if (CPP_OPTIONS (pfile)->warnings_are_errors)
+ pfile->errors++;
+
+ cpp_print_containing_files (pfile);
+
+ ip = cpp_file_buffer (pfile);
+
+ if (ip != NULL)
+ cpp_file_line_for_message (pfile, ip->nominal_fname, line, -1);
+
+ cpp_message (pfile, 0, msg, arg1, arg2, arg3);
+}
+
+void
+cpp_pedwarn_with_line (pfile, line, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ int line;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ if (CPP_OPTIONS (pfile)->pedantic_errors)
+ cpp_error_with_line (pfile, line, msg, arg1, arg2, arg3);
+ else
+ cpp_warning_with_line (pfile, line, msg, arg1, arg2, arg3);
+}
+
+/* Report a warning (or an error if pedantic_errors)
+ giving specified file name and line number, not current. */
+
+void
+cpp_pedwarn_with_file_and_line (pfile, file, line, msg, arg1, arg2, arg3)
+ cpp_reader *pfile;
+ char *file;
+ int line;
+ char *msg;
+ char *arg1, *arg2, *arg3;
+{
+ if (!CPP_OPTIONS (pfile)->pedantic_errors
+ && CPP_OPTIONS (pfile)->inhibit_warnings)
+ return;
+ if (file != NULL)
+ cpp_file_line_for_message (pfile, file, line, -1);
+ cpp_message (pfile, CPP_OPTIONS (pfile)->pedantic_errors,
+ msg, arg1, arg2, arg3);
+}
+
+/* This defines "errno" properly for VMS, and gives us EACCES. */
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+
+#ifndef VMS
+#ifndef HAVE_STRERROR
+extern int sys_nerr;
+#if defined(bsd4_4)
+extern const char *const sys_errlist[];
+#else
+extern char *sys_errlist[];
+#endif
+#else /* HAVE_STERRROR */
+char *strerror ();
+#endif
+#else /* VMS */
+char *strerror (int,...);
+#endif
+
+/*
+ * my_strerror - return the descriptive text associated with an `errno' code.
+ */
+
+char *
+my_strerror (errnum)
+ int errnum;
+{
+ char *result;
+
+#ifndef VMS
+#ifndef HAVE_STRERROR
+ result = (char *) ((errnum < sys_nerr) ? sys_errlist[errnum] : 0);
+#else
+ result = strerror (errnum);
+#endif
+#else /* VMS */
+ /* VAXCRTL's strerror() takes an optional second argument, which only
+ matters when the first argument is EVMSERR. However, it's simplest
+ just to pass it unconditionally. `vaxc$errno' is declared in
+ <errno.h>, and maintained by the library in parallel with `errno'.
+ We assume that caller's `errnum' either matches the last setting of
+ `errno' by the library or else does not have the value `EVMSERR'. */
+
+ result = strerror (errnum, vaxc$errno);
+#endif
+
+ if (!result)
+ result = "undocumented I/O error";
+
+ return result;
+}
+
+/* Error including a message from `errno'. */
+
+void
+cpp_error_from_errno (pfile, name)
+ cpp_reader *pfile;
+ char *name;
+{
+ int i;
+ cpp_buffer *ip = cpp_file_buffer (pfile);
+
+ cpp_print_containing_files (pfile);
+
+ if (ip != NULL)
+ cpp_file_line_for_message (pfile, ip->nominal_fname, ip->lineno, -1);
+
+ cpp_message (pfile, 1, "%s: %s\n", name, my_strerror (errno));
+}
+
+void
+cpp_perror_with_name (pfile, name)
+ cpp_reader *pfile;
+ char *name;
+{
+ cpp_message (pfile, 1, "%s: %s: %s\n", progname, name, my_strerror (errno));
+}
/* TODO:
* No pre-compiled header file support.
@@ -7306,7 +7524,7 @@ cpp_read_check_assertion (pfile)
*
* Support -dM flag (dump_all_macros).
*
- * -include should be made to returns results incrementally.
+ * -include should be made to return results incrementally.
* (current implementation only works when cpp is used as main program)
*
*/