aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--gcc/ChangeLog22
-rw-r--r--gcc/genattrtab.c4
-rw-r--r--gcc/genoutput.c2
-rw-r--r--gcc/gensupport.c2
-rw-r--r--gcc/read-md.c33
-rw-r--r--gcc/read-md.h16
6 files changed, 63 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8aa75ab..60aeafb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,25 @@
+2016-10-04 David Malcolm <dmalcolm@redhat.com>
+
+ * 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.
+
2016-10-04 Jakub Jelinek <jakub@redhat.com>
* doc/extend.texi (Java Exceptions): Remove.
diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 3b47f34..6e0a9b9 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -4659,7 +4659,7 @@ make_internal_attr (const char *name, rtx value, int special)
attr->is_numeric = 1;
attr->is_const = 0;
attr->is_special = (special & ATTR_SPECIAL) != 0;
- attr->default_val = get_attr_value (file_location ("<internal>", 0),
+ attr->default_val = get_attr_value (file_location ("<internal>", 0, 0),
value, attr, -2);
}
@@ -5281,7 +5281,7 @@ main (int argc, const char **argv)
md_rtx_info info;
info.def = rtx_alloc (DEFINE_ASM_ATTRIBUTES);
XVEC (info.def, 0) = rtvec_alloc (0);
- info.loc = file_location ("<internal>", 0);
+ info.loc = file_location ("<internal>", 0, 0);
info.index = -1;
gen_insn (&info);
}
diff --git a/gcc/genoutput.c b/gcc/genoutput.c
index 5909258..f792cb4 100644
--- a/gcc/genoutput.c
+++ b/gcc/genoutput.c
@@ -980,7 +980,7 @@ init_insn_for_nothing (void)
idata = XCNEW (struct data);
new (idata) data ();
idata->name = "*placeholder_for_nothing";
- idata->loc = file_location ("<internal>", 0);
+ idata->loc = file_location ("<internal>", 0, 0);
idata_end = &idata->next;
}
diff --git a/gcc/gensupport.c b/gcc/gensupport.c
index 1648c9c..cb74aea 100644
--- a/gcc/gensupport.c
+++ b/gcc/gensupport.c
@@ -446,7 +446,7 @@ add_define_attr (const char *name)
XEXP (t1, 2) = rtx_alloc (CONST_STRING);
XSTR (XEXP (t1, 2), 0) = "yes";
e->data = t1;
- e->loc = file_location ("built-in", -1);
+ e->loc = file_location ("built-in", -1, -1);
e->next = define_attr_queue;
define_attr_queue = e;
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. */
diff --git a/gcc/read-md.h b/gcc/read-md.h
index 82a628b..a74cc72 100644
--- a/gcc/read-md.h
+++ b/gcc/read-md.h
@@ -25,14 +25,15 @@ along with GCC; see the file COPYING3. If not see
/* Records a position in the file. */
struct file_location {
file_location () {}
- file_location (const char *, int);
+ file_location (const char *, int, int);
const char *filename;
int lineno;
+ int colno;
};
-inline file_location::file_location (const char *filename_in, int lineno_in)
- : filename (filename_in), lineno (lineno_in) {}
+inline file_location::file_location (const char *filename_in, int lineno_in, int colno_in)
+: filename (filename_in), lineno (lineno_in), colno (colno_in) {}
/* Holds one symbol or number in the .md file. */
struct md_name {
@@ -112,6 +113,7 @@ class rtx_reader
const char *get_top_level_filename () const { return m_toplevel_fname; }
const char *get_filename () const { return m_read_md_filename; }
int get_lineno () const { return m_read_md_lineno; }
+ int get_colno () const { return m_read_md_colno; }
private:
/* A singly-linked list of filenames. */
@@ -144,6 +146,14 @@ class rtx_reader
/* The current line number in m_read_md_file. */
int m_read_md_lineno;
+ /* The current column number in m_read_md_file. */
+ int m_read_md_colno;
+
+ /* The column number before the last newline, so that
+ we can handle unread_char ('\n') at least once whilst
+ retaining column information. */
+ int m_last_line_colno;
+
/* The first directory to search. */
file_name_list *m_first_dir_md_include;