aboutsummaryrefslogtreecommitdiff
path: root/gcc/read-md.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-10-04 17:10:41 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-10-04 17:10:41 +0000
commit3814e88007d6d9abfbdfd53dbcdc92fe1aed23de (patch)
tree674c22b9fe8aab5e932b8be9edc880125ec3af7d /gcc/read-md.c
parentf72da967576271070086b2252a8463bb69f93abd (diff)
downloadgcc-3814e88007d6d9abfbdfd53dbcdc92fe1aed23de.zip
gcc-3814e88007d6d9abfbdfd53dbcdc92fe1aed23de.tar.gz
gcc-3814e88007d6d9abfbdfd53dbcdc92fe1aed23de.tar.bz2
read-md.c: track column numbers
gcc/ChangeLog: * genattrtab.c (make_internal_attr): Supply dummy column number to file_location ctor. (main): Likewise. * genoutput.c (init_insn_for_nothing): Likewise. * gensupport.c (add_define_attr): Likewise. * read-md.c (message_at_1): Print column number. (fatal_with_file_and_line): Likewise. (rtx_reader::read_char): Track column numbers. (rtx_reader::unread_char): Likewise. (rtx_reader::rtx_reader): Initialize m_read_md_colno. (rtx_reader::handle_include): Stash and restore m_read_md_colno. (rtx_reader::handle_file): Initialize m_read_md_colno. (rtx_reader::get_current_location): Supply column number to file_location ctor. * read-md.h (struct file_location): Add field "colno". (file_location::file_location): Likewise. (rtx_reader::get_colno): New accessor. (rtx_reader::m_read_md_colno): New field. (rtx_reader::m_last_line_colno): New field. From-SVN: r240752
Diffstat (limited to 'gcc/read-md.c')
-rw-r--r--gcc/read-md.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c
index f069ba5a..e158be5 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -218,7 +218,7 @@ print_c_condition (const char *cond)
static void ATTRIBUTE_PRINTF(2,0)
message_at_1 (file_location loc, const char *msg, va_list ap)
{
- fprintf (stderr, "%s:%d: ", loc.filename, loc.lineno);
+ fprintf (stderr, "%s:%d:%d: ", loc.filename, loc.lineno, loc.colno);
vfprintf (stderr, msg, ap);
fputc ('\n', stderr);
}
@@ -274,8 +274,8 @@ fatal_with_file_and_line (const char *msg, ...)
va_start (ap, msg);
- fprintf (stderr, "%s:%d: error: ", rtx_reader_ptr->get_filename (),
- rtx_reader_ptr->get_lineno ());
+ fprintf (stderr, "%s:%d:%d: error: ", rtx_reader_ptr->get_filename (),
+ rtx_reader_ptr->get_lineno (), rtx_reader_ptr->get_colno ());
vfprintf (stderr, msg, ap);
putc ('\n', stderr);
@@ -294,9 +294,9 @@ fatal_with_file_and_line (const char *msg, ...)
}
context[i] = '\0';
- fprintf (stderr, "%s:%d: note: following context is `%s'\n",
+ fprintf (stderr, "%s:%d:%d: note: following context is `%s'\n",
rtx_reader_ptr->get_filename (), rtx_reader_ptr->get_lineno (),
- context);
+ rtx_reader_ptr->get_colno (), context);
va_end (ap);
exit (1);
@@ -384,7 +384,13 @@ rtx_reader::read_char (void)
ch = getc (m_read_md_file);
if (ch == '\n')
- m_read_md_lineno++;
+ {
+ m_read_md_lineno++;
+ m_last_line_colno = m_read_md_colno;
+ m_read_md_colno = 0;
+ }
+ else
+ m_read_md_colno++;
return ch;
}
@@ -395,7 +401,12 @@ void
rtx_reader::unread_char (int ch)
{
if (ch == '\n')
- m_read_md_lineno--;
+ {
+ m_read_md_lineno--;
+ m_read_md_colno = m_last_line_colno;
+ }
+ else
+ m_read_md_colno--;
ungetc (ch, m_read_md_file);
}
@@ -908,6 +919,7 @@ rtx_reader::rtx_reader ()
m_read_md_file (NULL),
m_read_md_filename (NULL),
m_read_md_lineno (0),
+ m_read_md_colno (0),
m_first_dir_md_include (NULL),
m_last_dir_md_include_ptr (&m_first_dir_md_include)
{
@@ -933,7 +945,7 @@ rtx_reader::handle_include (file_location loc)
{
const char *filename;
const char *old_filename;
- int old_lineno;
+ int old_lineno, old_colno;
char *pathname;
FILE *input_file, *old_file;
@@ -982,6 +994,7 @@ rtx_reader::handle_include (file_location loc)
old_file = m_read_md_file;
old_filename = m_read_md_filename;
old_lineno = m_read_md_lineno;
+ old_colno = m_read_md_colno;
if (include_callback)
include_callback (pathname);
@@ -995,6 +1008,7 @@ rtx_reader::handle_include (file_location loc)
m_read_md_file = old_file;
m_read_md_filename = old_filename;
m_read_md_lineno = old_lineno;
+ m_read_md_colno = old_colno;
/* Do not free the pathname. It is attached to the various rtx
queue elements. */
@@ -1011,6 +1025,7 @@ rtx_reader::handle_file ()
int c;
m_read_md_lineno = 1;
+ m_read_md_colno = 0;
while ((c = read_skip_spaces ()) != EOF)
{
file_location loc = get_current_location ();
@@ -1055,7 +1070,7 @@ rtx_reader::handle_toplevel_file ()
file_location
rtx_reader::get_current_location () const
{
- return file_location (m_read_md_filename, m_read_md_lineno);
+ return file_location (m_read_md_filename, m_read_md_lineno, m_read_md_colno);
}
/* Parse a -I option with argument ARG. */