aboutsummaryrefslogtreecommitdiff
path: root/gcc/read-md.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2015-07-16 13:41:41 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2015-07-16 13:41:41 +0000
commitcc4726077d61d3c73edf2e909a397d78ec447540 (patch)
treea86b33cb3517b785698d786a2d59d9caef97b308 /gcc/read-md.c
parent1e2e5efadd0147f249be5bd4e32f91c9e571824b (diff)
downloadgcc-cc4726077d61d3c73edf2e909a397d78ec447540.zip
gcc-cc4726077d61d3c73edf2e909a397d78ec447540.tar.gz
gcc-cc4726077d61d3c73edf2e909a397d78ec447540.tar.bz2
read-md.h (file_location): New structure.
gcc/ * read-md.h (file_location): New structure. (directive_handler_t): Take a file_location rather than a line number. (message_at, error_at): Declare. (read_skip_construct): Delete. * read-md.c (message_with_line_1): Replace with... (message_at_1): ...this new function. (message_at, error_at): New functions. (message_with_line, error_with_line): Update to use message_at_1. (handle_enum): Take a file_location rather than a line number and use error_at for error reporting. (handle_include): Likewise. (read_skip_construct): Likewise. Make static. (handle_file): Update after above changes. Pass a file_location rather than a line number to handle_directive. * gensupport.c (queue_elem): Replace separate filename and lineno with a file_location. (queue_pattern): Replace filename and lineno arguments with a file_location. Update after change to queue_elem. (process_define_predicate): Replace lineno argument with a file_location and use error_at for error reporting. Update after above changes. (process_rtx): Likewise. (subst_pattern_match): Likewise. (get_alternatives_number): Likewise. (alter_predicate_for_insn): Likewise. (rtx_handle_directive): Likewise. (is_predicable): Update after above changes, using error_at rather than error_with_line. (has_subst_attribute): Likewise. (identify_predicable_attribute): Likewise. (alter_attrs_for_subst_insn): Likewise. (process_one_cond_exec): Likewise. (process_substs_on_one_elem): Likewise. (process_define_subst): Likewise. (check_define_attr_duplicates): Likewise. (read_md_rtx): Update after change to queue_elem. From-SVN: r225879
Diffstat (limited to 'gcc/read-md.c')
-rw-r--r--gcc/read-md.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c
index 41c2316..d93b116 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -245,13 +245,38 @@ print_c_condition (const char *cond)
of the current MD file. */
static void ATTRIBUTE_PRINTF(2,0)
-message_with_line_1 (int lineno, const char *msg, va_list ap)
+message_at_1 (file_location loc, const char *msg, va_list ap)
{
- fprintf (stderr, "%s:%d: ", read_md_filename, lineno);
+ fprintf (stderr, "%s:%d: ", loc.filename, loc.lineno);
vfprintf (stderr, msg, ap);
fputc ('\n', stderr);
}
+/* A printf-like function for reporting a message against location LOC. */
+
+void
+message_at (file_location loc, const char *msg, ...)
+{
+ va_list ap;
+
+ va_start (ap, msg);
+ message_at_1 (loc, msg, ap);
+ va_end (ap);
+}
+
+/* Like message_at, but treat the condition as an error. */
+
+void
+error_at (file_location loc, const char *msg, ...)
+{
+ va_list ap;
+
+ va_start (ap, msg);
+ message_at_1 (loc, msg, ap);
+ va_end (ap);
+ have_error = 1;
+}
+
/* A printf-like function for reporting an error against line LINENO
in the current MD file. */
@@ -261,7 +286,7 @@ message_with_line (int lineno, const char *msg, ...)
va_list ap;
va_start (ap, msg);
- message_with_line_1 (lineno, msg, ap);
+ message_at_1 (file_location (read_md_filename, lineno), msg, ap);
va_end (ap);
}
@@ -273,7 +298,7 @@ error_with_line (int lineno, const char *msg, ...)
va_list ap;
va_start (ap, msg);
- message_with_line_1 (lineno, msg, ap);
+ message_at_1 (file_location (read_md_filename, lineno), msg, ap);
va_end (ap);
have_error = 1;
}
@@ -593,8 +618,8 @@ read_string (int star_if_braced)
/* Skip the rest of a construct that started at line LINENO and that
is currently nested by DEPTH levels of parentheses. */
-void
-read_skip_construct (int depth, int lineno)
+static void
+read_skip_construct (int depth, file_location loc)
{
struct md_name name;
int c;
@@ -604,7 +629,7 @@ read_skip_construct (int depth, int lineno)
c = read_skip_spaces ();
if (c == EOF)
{
- error_with_line (lineno, "unterminated construct");
+ error_at (loc, "unterminated construct");
exit (1);
}
switch (c)
@@ -794,7 +819,7 @@ md_decimal_string (int number)
directive is a define_enum rather than a define_c_enum. */
static void
-handle_enum (int lineno, bool md_p)
+handle_enum (file_location loc, bool md_p)
{
char *enum_name, *value_name;
struct md_name name;
@@ -809,8 +834,8 @@ handle_enum (int lineno, bool md_p)
{
def = (struct enum_type *) *slot;
if (def->md_p != md_p)
- error_with_line (lineno, "redefining `%s' as a different type of enum",
- enum_name);
+ error_at (loc, "redefining `%s' as a different type of enum",
+ enum_name);
}
else
{
@@ -831,7 +856,7 @@ handle_enum (int lineno, bool md_p)
{
if (c == EOF)
{
- error_with_line (lineno, "unterminated construct");
+ error_at (loc, "unterminated construct");
exit (1);
}
unread_char (c);
@@ -883,7 +908,7 @@ traverse_enum_types (htab_trav callback, void *info)
which the "include" occurred. */
static void
-handle_include (int lineno, directive_handler_t handle_directive)
+handle_include (file_location loc, directive_handler_t handle_directive)
{
const char *filename;
const char *old_filename;
@@ -926,7 +951,7 @@ handle_include (int lineno, directive_handler_t handle_directive)
if (input_file == NULL)
{
free (pathname);
- error_with_line (lineno, "include file `%s' not found", filename);
+ error_at (loc, "include file `%s' not found", filename);
return;
}
@@ -961,12 +986,12 @@ static void
handle_file (directive_handler_t handle_directive)
{
struct md_name directive;
- int c, lineno;
+ int c;
read_md_lineno = 1;
while ((c = read_skip_spaces ()) != EOF)
{
- lineno = read_md_lineno;
+ file_location loc (read_md_filename, read_md_lineno);
if (c != '(')
fatal_expected_char ('(', c);
@@ -974,15 +999,15 @@ handle_file (directive_handler_t handle_directive)
if (strcmp (directive.string, "define_constants") == 0)
handle_constants ();
else if (strcmp (directive.string, "define_enum") == 0)
- handle_enum (lineno, true);
+ handle_enum (loc, true);
else if (strcmp (directive.string, "define_c_enum") == 0)
- handle_enum (lineno, false);
+ handle_enum (loc, false);
else if (strcmp (directive.string, "include") == 0)
- handle_include (lineno, handle_directive);
+ handle_include (loc, handle_directive);
else if (handle_directive)
- handle_directive (lineno, directive.string);
+ handle_directive (loc, directive.string);
else
- read_skip_construct (1, lineno);
+ read_skip_construct (1, loc);
c = read_skip_spaces ();
if (c != ')')