+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.
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);
}
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);
}
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;
}
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;
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);
}
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);
}
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);
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;
}
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);
}
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)
{
{
const char *filename;
const char *old_filename;
- int old_lineno;
+ int old_lineno, old_colno;
char *pathname;
FILE *input_file, *old_file;
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);
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. */
int c;
m_read_md_lineno = 1;
+ m_read_md_colno = 0;
while ((c = read_skip_spaces ()) != EOF)
{
file_location loc = get_current_location ();
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. */
/* 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 {
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. */
/* 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;