+2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * Makefile.in (build/read-md.o): Depend on errors.h.
+ * read-md.h (error_with_line): Declare.
+ * read-md.c: Include errors.h.
+ (message_with_line_1): New function, extracted from...
+ (message_with_line): ...here.
+ (error_with_line): New function.
+ * genattrtab.c: If a call to message_with_line is followed by
+ "have_error = 1;", replace both statements with a call to
+ error_with_line.
+ * genoutput.c: Likewise.
+ * genpreds.c: Likewise.
+ * genrecog.c: If a call to message_with_line is followed by
+ "error_count++;", replace both statements with a call to
+ error_with_line.
+ (errorcount): Delete.
+ (main): Don't check it.
+ * gensupport.c: If a call to message_with_line is followed by
+ "errors = 1;", replace both statements with a call to error_with_line.
+ (errors): Delete.
+ (process_define_cond_exec): Check have_error instead of errors.
+ (init_md_reader_args_cb): Likewise. Don't set errors.
+
2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
* read-md.h (read_md_file): Declare.
build/print-rtl.o: print-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
$(GTM_H) $(RTL_BASE_H)
build/read-md.o: read-md.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
- $(HASHTAB_H) $(READ_MD_H)
+ $(HASHTAB_H) errors.h $(READ_MD_H)
build/read-rtl.o: read-rtl.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h \
$(GTM_H) $(RTL_BASE_H) $(OBSTACK_H) $(HASHTAB_H) $(READ_MD_H) \
gensupport.h
case CONST_INT:
if (attr && ! attr->is_numeric)
{
- message_with_line (attr->lineno,
- "CONST_INT not valid for non-numeric attribute %s",
- attr->name);
- have_error = 1;
+ error_with_line (attr->lineno,
+ "CONST_INT not valid for non-numeric attribute %s",
+ attr->name);
break;
}
if (INTVAL (exp) < 0)
{
- message_with_line (attr->lineno,
- "negative numeric value specified for attribute %s",
- attr->name);
- have_error = 1;
+ error_with_line (attr->lineno,
+ "negative numeric value specified for attribute %s",
+ attr->name);
break;
}
break;
for (; *p; p++)
if (! ISDIGIT (*p))
{
- message_with_line (attr ? attr->lineno : 0,
- "non-numeric value for numeric attribute %s",
- attr ? attr->name : "internal");
- have_error = 1;
+ error_with_line (attr ? attr->lineno : 0,
+ "non-numeric value for numeric attribute %s",
+ attr ? attr->name : "internal");
break;
}
break;
break;
if (av == NULL)
- {
- message_with_line (attr->lineno,
- "unknown value `%s' for `%s' attribute",
- XSTR (exp, 0), attr ? attr->name : "internal");
- have_error = 1;
- }
+ error_with_line (attr->lineno,
+ "unknown value `%s' for `%s' attribute",
+ XSTR (exp, 0), attr ? attr->name : "internal");
break;
case IF_THEN_ELSE:
case MOD:
if (attr && !attr->is_numeric)
{
- message_with_line (attr->lineno,
- "invalid operation `%s' for non-numeric attribute value",
- GET_RTX_NAME (GET_CODE (exp)));
- have_error = 1;
+ error_with_line (attr->lineno,
+ "invalid operation `%s' for non-numeric"
+ " attribute value", GET_RTX_NAME (GET_CODE (exp)));
break;
}
/* Fall through. */
case COND:
if (XVECLEN (exp, 0) % 2 != 0)
{
- message_with_line (attr->lineno,
- "first operand of COND must have even length");
- have_error = 1;
+ error_with_line (attr->lineno,
+ "first operand of COND must have even length");
break;
}
{
struct attr_desc *attr2 = find_attr (&XSTR (exp, 0), 0);
if (attr2 == NULL)
- {
- message_with_line (attr ? attr->lineno : 0,
- "unknown attribute `%s' in ATTR",
- XSTR (exp, 0));
- have_error = 1;
- }
+ error_with_line (attr ? attr->lineno : 0,
+ "unknown attribute `%s' in ATTR",
+ XSTR (exp, 0));
else if (attr && attr->is_const && ! attr2->is_const)
- {
- message_with_line (attr->lineno,
- "non-constant attribute `%s' referenced from `%s'",
- XSTR (exp, 0), attr->name);
- have_error = 1;
- }
+ error_with_line (attr->lineno,
+ "non-constant attribute `%s' referenced from `%s'",
+ XSTR (exp, 0), attr->name);
else if (attr
&& attr->is_numeric != attr2->is_numeric)
- {
- message_with_line (attr->lineno,
- "numeric attribute mismatch calling `%s' from `%s'",
- XSTR (exp, 0), attr->name);
- have_error = 1;
- }
+ error_with_line (attr->lineno,
+ "numeric attribute mismatch calling `%s' from `%s'",
+ XSTR (exp, 0), attr->name);
}
break;
return attr_rtx (SYMBOL_REF, XSTR (exp, 0));
default:
- message_with_line (attr ? attr->lineno : 0,
- "invalid operation `%s' for attribute value",
- GET_RTX_NAME (GET_CODE (exp)));
- have_error = 1;
+ error_with_line (attr ? attr->lineno : 0,
+ "invalid operation `%s' for attribute value",
+ GET_RTX_NAME (GET_CODE (exp)));
break;
}
if (XVECLEN (exp, 1) != num_alt)
{
- message_with_line (id->lineno,
- "bad number of entries in SET_ATTR_ALTERNATIVE");
- have_error = 1;
+ error_with_line (id->lineno,
+ "bad number of entries in SET_ATTR_ALTERNATIVE");
return NULL_RTX;
}
case SET:
if (GET_CODE (XEXP (value, 0)) != ATTR)
{
- message_with_line (id->lineno, "bad attribute set");
- have_error = 1;
+ error_with_line (id->lineno, "bad attribute set");
value = NULL_RTX;
}
break;
break;
default:
- message_with_line (id->lineno, "invalid attribute code %s",
- GET_RTX_NAME (GET_CODE (value)));
- have_error = 1;
+ error_with_line (id->lineno, "invalid attribute code %s",
+ GET_RTX_NAME (GET_CODE (value)));
value = NULL_RTX;
}
if (value == NULL_RTX)
if ((attr = find_attr (&XSTR (XEXP (value, 0), 0), 0)) == NULL)
{
- message_with_line (id->lineno, "unknown attribute %s",
- XSTR (XEXP (value, 0), 0));
- have_error = 1;
+ error_with_line (id->lineno, "unknown attribute %s",
+ XSTR (XEXP (value, 0), 0));
continue;
}
attr = find_attr (&XSTR (exp, 0), 1);
if (attr->default_val)
{
- message_with_line (lineno, "duplicate definition for attribute %s",
- attr->name);
+ error_with_line (lineno, "duplicate definition for attribute %s",
+ attr->name);
message_with_line (attr->lineno, "previous definition");
- have_error = 1;
return;
}
attr->lineno = lineno;
{
attr->is_const = 1;
if (attr->is_numeric)
- {
- message_with_line (lineno,
- "constant attributes may not take numeric values");
- have_error = 1;
- }
+ error_with_line (lineno,
+ "constant attributes may not take numeric values");
/* Get rid of the CONST node. It is allowed only at top-level. */
XEXP (exp, 2) = XEXP (XEXP (exp, 2), 0);
}
if (! strcmp_check (attr->name, length_str) && ! attr->is_numeric)
- {
- message_with_line (lineno,
- "`length' attribute must take numeric values");
- have_error = 1;
- }
+ error_with_line (lineno, "`length' attribute must take numeric values");
/* Set up the default value. */
XEXP (exp, 2) = check_attr_value (XEXP (exp, 2), attr);
if (XVECLEN (def, 1) % 3 != 0)
{
- message_with_line (lineno,
- "number of elements in DEFINE_DELAY must be multiple of three");
- have_error = 1;
+ error_with_line (lineno,
+ "number of elements in DEFINE_DELAY must"
+ " be multiple of three");
return;
}
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
- message_with_line (d->lineno,
- "maximum number of operands exceeded");
- have_error = 1;
+ error_with_line (d->lineno, "maximum number of operands exceeded");
return;
}
if (d->operand[opno].seen)
- {
- message_with_line (d->lineno,
- "repeated operand number %d\n", opno);
- have_error = 1;
- }
+ error_with_line (d->lineno, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
- message_with_line (d->lineno,
- "maximum number of operands exceeded");
- have_error = 1;
+ error_with_line (d->lineno, "maximum number of operands exceeded");
return;
}
if (d->operand[opno].seen)
- {
- message_with_line (d->lineno,
- "repeated operand number %d\n", opno);
- have_error = 1;
- }
+ error_with_line (d->lineno, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
max_opno = opno;
if (max_opno >= MAX_MAX_OPERANDS)
{
- message_with_line (d->lineno,
- "maximum number of operands exceeded");
- have_error = 1;
+ error_with_line (d->lineno, "maximum number of operands exceeded");
return;
}
if (d->operand[opno].seen)
- {
- message_with_line (d->lineno,
- "repeated operand number %d\n", opno);
- have_error = 1;
- }
+ error_with_line (d->lineno, "repeated operand number %d\n", opno);
d->operand[opno].seen = 1;
d->operand[opno].mode = GET_MODE (part);
message_with_line (d->lineno,
"'@' is redundant for output template with single alternative");
if (i != d->n_alternatives)
- {
- message_with_line (d->lineno,
- "wrong number of alternatives in the output template");
- have_error = 1;
- }
+ error_with_line (d->lineno,
+ "wrong number of alternatives in the output template");
printf ("};\n");
}
if (len < 1 || (len > 1 && strchr (",#*+=&%!0123456789", c)))
{
- message_with_line (d->lineno,
- "invalid length %d for char '%c' in alternative %d of operand %d",
- len, c, which_alternative, start);
+ error_with_line (d->lineno,
+ "invalid length %d for char '%c' in"
+ " alternative %d of operand %d",
+ len, c, which_alternative, start);
len = 1;
- have_error = 1;
}
#endif
for (i = 1; i < len; i++)
if (p[i] == '\0')
{
- message_with_line (d->lineno,
- "NUL in alternative %d of operand %d",
- which_alternative, start);
+ error_with_line (d->lineno,
+ "NUL in alternative %d of operand %d",
+ which_alternative, start);
alternative_count_unsure = 1;
break;
}
else if (strchr (",#*", p[i]))
{
- message_with_line (d->lineno,
- "'%c' in alternative %d of operand %d",
- p[i], which_alternative, start);
+ error_with_line (d->lineno,
+ "'%c' in alternative %d of operand %d",
+ p[i], which_alternative, start);
alternative_count_unsure = 1;
}
}
- if (alternative_count_unsure)
- have_error = 1;
- else if (n == 0)
- n = d->operand[start].n_alternatives;
- else if (n != d->operand[start].n_alternatives)
+ if (!alternative_count_unsure)
{
- message_with_line (d->lineno,
+ if (n == 0)
+ n = d->operand[start].n_alternatives;
+ else if (n != d->operand[start].n_alternatives)
+ error_with_line (d->lineno,
"wrong number of alternatives in operand %d",
start);
- have_error = 1;
}
}
for (i = 0; i < d->n_operands; ++i)
if (d->operand[i].seen == 0)
- {
- message_with_line (d->lineno, "missing operand %d", i);
- have_error = 1;
- }
+ error_with_line (d->lineno, "missing operand %d", i);
}
static void
if (strchr (indep_constraints, name[0]) && name[0] != 'm')
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint letter '%s' cannot be "
- "redefined by the machine description", name);
+ error_with_line (lineno, "constraint letter '%s' cannot be "
+ "redefined by the machine description", name);
else
- message_with_line (lineno, "constraint name '%s' cannot be defined by "
- "the machine description, as it begins with '%c'",
- name, name[0]);
- have_error = 1;
+ error_with_line (lineno, "constraint name '%s' cannot be defined by "
+ "the machine description, as it begins with '%c'",
+ name, name[0]);
return;
}
if (!strcmp ((*iter)->name, name))
{
- message_with_line (lineno, "redefinition of constraint '%s'", name);
+ error_with_line (lineno, "redefinition of constraint '%s'", name);
message_with_line ((*iter)->lineno, "previous definition is here");
- have_error = 1;
return;
}
else if (!strncmp ((*iter)->name, name, (*iter)->namelen))
{
- message_with_line (lineno, "defining constraint '%s' here", name);
+ error_with_line (lineno, "defining constraint '%s' here", name);
message_with_line ((*iter)->lineno, "renders constraint '%s' "
"(defined here) a prefix", (*iter)->name);
- have_error = 1;
return;
}
else if (!strncmp ((*iter)->name, name, namelen))
{
- message_with_line (lineno, "constraint '%s' is a prefix", name);
+ error_with_line (lineno, "constraint '%s' is a prefix", name);
message_with_line ((*iter)->lineno, "of constraint '%s' "
"(defined here)", (*iter)->name);
- have_error = 1;
return;
}
}
if (!strncmp (s, p->name, p->namelen))
return p->namelen;
- message_with_line (lineno,
- "error: undefined machine-specific constraint "
- "at this point: \"%s\"", s);
+ error_with_line (lineno,
+ "error: undefined machine-specific constraint "
+ "at this point: \"%s\"", s);
message_with_line (lineno, "note: in operand %d", opno);
- have_error = 1;
return 1; /* safe */
}
{
if (!ISDIGIT (*p) && !ISLOWER (*p))
{
- message_with_line (lineno, "%s: invalid character in path "
- "string '%s'", name, XSTR (exp, 1));
- have_error = 1;
+ error_with_line (lineno, "%s: invalid character in path "
+ "string '%s'", name, XSTR (exp, 1));
return true;
}
}
return false;
default:
- message_with_line (lineno,
- "%s: cannot use '%s' in a predicate expression",
- name, GET_RTX_NAME (GET_CODE (exp)));
- have_error = 1;
+ error_with_line (lineno,
+ "%s: cannot use '%s' in a predicate expression",
+ name, GET_RTX_NAME (GET_CODE (exp)));
return true;
}
}
return;
bad_name:
- message_with_line (lineno,
- "%s: predicate name must be a valid C function name",
- XSTR (defn, 0));
- have_error = 1;
+ error_with_line (lineno,
+ "%s: predicate name must be a valid C function name",
+ XSTR (defn, 0));
return;
}
if (!ISALPHA (name[0]) && name[0] != '_')
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint name '%s' is not "
- "a letter or underscore", name);
+ error_with_line (lineno, "constraint name '%s' is not "
+ "a letter or underscore", name);
else
- message_with_line (lineno, "constraint name '%s' does not begin "
- "with a letter or underscore", name);
- have_error = 1;
+ error_with_line (lineno, "constraint name '%s' does not begin "
+ "with a letter or underscore", name);
return;
}
for (p = name; *p; p++)
need_mangled_name = true;
else
{
- message_with_line (lineno,
- "constraint name '%s' must be composed of "
- "letters, digits, underscores, and "
- "angle brackets", name);
- have_error = 1;
+ error_with_line (lineno,
+ "constraint name '%s' must be composed of "
+ "letters, digits, underscores, and "
+ "angle brackets", name);
return;
}
}
if (strchr (generic_constraint_letters, name[0]))
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint letter '%s' cannot be "
- "redefined by the machine description", name);
+ error_with_line (lineno, "constraint letter '%s' cannot be "
+ "redefined by the machine description", name);
else
- message_with_line (lineno, "constraint name '%s' cannot be defined by "
- "the machine description, as it begins with '%c'",
- name, name[0]);
- have_error = 1;
+ error_with_line (lineno, "constraint name '%s' cannot be defined by "
+ "the machine description, as it begins with '%c'",
+ name, name[0]);
return;
}
if (!strcmp ((*iter)->name, name))
{
- message_with_line (lineno, "redefinition of constraint '%s'", name);
+ error_with_line (lineno, "redefinition of constraint '%s'", name);
message_with_line ((*iter)->lineno, "previous definition is here");
- have_error = 1;
return;
}
else if (!strncmp ((*iter)->name, name, (*iter)->namelen))
{
- message_with_line (lineno, "defining constraint '%s' here", name);
+ error_with_line (lineno, "defining constraint '%s' here", name);
message_with_line ((*iter)->lineno, "renders constraint '%s' "
"(defined here) a prefix", (*iter)->name);
- have_error = 1;
return;
}
else if (!strncmp ((*iter)->name, name, namelen))
{
- message_with_line (lineno, "constraint '%s' is a prefix", name);
+ error_with_line (lineno, "constraint '%s' is a prefix", name);
message_with_line ((*iter)->lineno, "of constraint '%s' "
"(defined here)", (*iter)->name);
- have_error = 1;
return;
}
}
GET_RTX_NAME (appropriate_code)))
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint letter '%c' is reserved "
- "for %s constraints",
- name[0], GET_RTX_NAME (appropriate_code));
+ error_with_line (lineno, "constraint letter '%c' is reserved "
+ "for %s constraints",
+ name[0], GET_RTX_NAME (appropriate_code));
else
- message_with_line (lineno, "constraint names beginning with '%c' "
- "(%s) are reserved for %s constraints",
- name[0], name,
- GET_RTX_NAME (appropriate_code));
-
- have_error = 1;
+ error_with_line (lineno, "constraint names beginning with '%c' "
+ "(%s) are reserved for %s constraints",
+ name[0], name, GET_RTX_NAME (appropriate_code));
return;
}
if (is_memory)
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint letter '%c' cannot be a "
- "memory constraint", name[0]);
+ error_with_line (lineno, "constraint letter '%c' cannot be a "
+ "memory constraint", name[0]);
else
- message_with_line (lineno, "constraint name '%s' begins with '%c', "
- "and therefore cannot be a memory constraint",
- name, name[0]);
-
- have_error = 1;
+ error_with_line (lineno, "constraint name '%s' begins with '%c', "
+ "and therefore cannot be a memory constraint",
+ name, name[0]);
return;
}
else if (is_address)
{
if (name[1] == '\0')
- message_with_line (lineno, "constraint letter '%c' cannot be a "
- "memory constraint", name[0]);
+ error_with_line (lineno, "constraint letter '%c' cannot be a "
+ "memory constraint", name[0]);
else
- message_with_line (lineno, "constraint name '%s' begins with '%c', "
- "and therefore cannot be a memory constraint",
- name, name[0]);
-
- have_error = 1;
+ error_with_line (lineno, "constraint name '%s' begins with '%c', "
+ "and therefore cannot be a memory constraint",
+ name, name[0]);
return;
}
}
/* The line number of the start of the pattern currently being processed. */
static int pattern_lineno;
-
-/* Count of errors. */
-static int error_count;
\f
/* Predicate handling.
if (*next_code == '\0')
{
- message_with_line (pattern_lineno, "empty match_code expression");
- error_count++;
+ error_with_line (pattern_lineno, "empty match_code expression");
break;
}
}
if (!found_it)
{
- message_with_line (pattern_lineno, "match_code \"%.*s\" matches nothing",
- (int) n, code);
- error_count ++;
+ error_with_line (pattern_lineno,
+ "match_code \"%.*s\" matches nothing",
+ (int) n, code);
for (i = 0; i < NUM_RTX_CODE; i++)
if (!strncasecmp (code, GET_RTX_NAME (i), n)
&& GET_RTX_NAME (i)[n] == '\0'
struct pred_data *p = lookup_predicate (XSTR (exp, 1));
if (!p)
{
- message_with_line (pattern_lineno,
- "reference to unknown predicate '%s'",
- XSTR (exp, 1));
- error_count++;
+ error_with_line (pattern_lineno,
+ "reference to unknown predicate '%s'",
+ XSTR (exp, 1));
break;
}
for (i = 0; i < NUM_RTX_CODE; i++)
break;
default:
- message_with_line (pattern_lineno,
- "'%s' cannot be used in a define_predicate expression",
- GET_RTX_NAME (GET_CODE (exp)));
- error_count++;
+ error_with_line (pattern_lineno,
+ "'%s' cannot be used in a define_predicate expression",
+ GET_RTX_NAME (GET_CODE (exp)));
memset (codes, I, NUM_RTX_CODE);
break;
}
case MATCH_OP_DUP:
case MATCH_PAR_DUP:
if (find_operand (insn, XINT (pattern, 0), pattern) == pattern)
- {
- message_with_line (pattern_lineno,
- "operand %i duplicated before defined",
- XINT (pattern, 0));
- error_count++;
- }
+ error_with_line (pattern_lineno,
+ "operand %i duplicated before defined",
+ XINT (pattern, 0));
break;
case MATCH_OPERAND:
case MATCH_OPERATOR:
&& find_matching_operand (insn, XINT (pattern, 0)))
;
else
- {
- message_with_line (pattern_lineno,
- "operand %d missing in-out reload",
- XINT (pattern, 0));
- error_count++;
- }
- }
- else if (constraints0 != '=' && constraints0 != '+')
- {
- message_with_line (pattern_lineno,
- "operand %d missing output reload",
+ error_with_line (pattern_lineno,
+ "operand %d missing in-out reload",
XINT (pattern, 0));
- error_count++;
}
+ else if (constraints0 != '=' && constraints0 != '+')
+ error_with_line (pattern_lineno,
+ "operand %d missing output reload",
+ XINT (pattern, 0));
}
}
/* The operands of a SET must have the same mode unless one
is VOIDmode. */
else if (dmode != VOIDmode && smode != VOIDmode && dmode != smode)
- {
- message_with_line (pattern_lineno,
- "mode mismatch in set: %smode vs %smode",
- GET_MODE_NAME (dmode), GET_MODE_NAME (smode));
- error_count++;
- }
+ error_with_line (pattern_lineno,
+ "mode mismatch in set: %smode vs %smode",
+ GET_MODE_NAME (dmode), GET_MODE_NAME (smode));
/* If only one of the operands is VOIDmode, and PC or CC0 is
not involved, it's probably a mistake. */
case LABEL_REF:
if (GET_MODE (XEXP (pattern, 0)) != VOIDmode)
- {
- message_with_line (pattern_lineno,
- "operand to label_ref %smode not VOIDmode",
- GET_MODE_NAME (GET_MODE (XEXP (pattern, 0))));
- error_count++;
- }
+ error_with_line (pattern_lineno,
+ "operand to label_ref %smode not VOIDmode",
+ GET_MODE_NAME (GET_MODE (XEXP (pattern, 0))));
break;
default:
}
else
{
- message_with_line (add->u.insn.lineno, "`%s' matches `%s'",
- get_insn_name (add->u.insn.code_number),
- get_insn_name (old->u.insn.code_number));
+ error_with_line (add->u.insn.lineno, "`%s' matches `%s'",
+ get_insn_name (add->u.insn.code_number),
+ get_insn_name (old->u.insn.code_number));
message_with_line (old->u.insn.lineno, "previous definition of `%s'",
get_insn_name (old->u.insn.code_number));
- error_count++;
}
}
}
}
- if (error_count || have_error)
+ if (have_error)
return FATAL_EXIT_CODE;
puts ("\n\n");
struct obstack *rtl_obstack = &obstack;
static int sequence_num;
-static int errors;
static int predicable_default;
static const char *predicable_true;
if (input_file == NULL)
{
free (pathname);
- message_with_line (lineno, "include file `%s' not found", filename);
- errors = 1;
+ error_with_line (lineno, "include file `%s' not found", filename);
return;
}
success:
case SET_ATTR_ALTERNATIVE:
if (strcmp (XSTR (sub, 0), "predicable") == 0)
{
- message_with_line (elem->lineno,
- "multiple alternatives for `predicable'");
- errors = 1;
+ error_with_line (elem->lineno,
+ "multiple alternatives for `predicable'");
return 0;
}
break;
/* ??? It would be possible to handle this if we really tried.
It's not easy though, and I'm not going to bother until it
really proves necessary. */
- message_with_line (elem->lineno,
- "non-constant value for `predicable'");
- errors = 1;
+ error_with_line (elem->lineno,
+ "non-constant value for `predicable'");
return 0;
default:
to do this. Delay this until we've got the basics solid. */
if (strchr (value, ',') != NULL)
{
- message_with_line (elem->lineno,
- "multiple alternatives for `predicable'");
- errors = 1;
+ error_with_line (elem->lineno, "multiple alternatives for `predicable'");
return 0;
}
if (strcmp (value, predicable_false) == 0)
return 0;
- message_with_line (elem->lineno,
- "unknown value `%s' for `predicable' attribute",
- value);
- errors = 1;
+ error_with_line (elem->lineno,
+ "unknown value `%s' for `predicable' attribute", value);
return 0;
}
if (strcmp (XSTR (elem->data, 0), "predicable") == 0)
goto found;
- message_with_line (define_cond_exec_queue->lineno,
- "attribute `predicable' not defined");
- errors = 1;
+ error_with_line (define_cond_exec_queue->lineno,
+ "attribute `predicable' not defined");
return;
found:
p_true = strchr (p_false, ',');
if (p_true == NULL || strchr (++p_true, ',') != NULL)
{
- message_with_line (elem->lineno,
- "attribute `predicable' is not a boolean");
- errors = 1;
+ error_with_line (elem->lineno, "attribute `predicable' is not a boolean");
if (p_false)
free (p_false);
return;
break;
case CONST:
- message_with_line (elem->lineno,
- "attribute `predicable' cannot be const");
- errors = 1;
+ error_with_line (elem->lineno, "attribute `predicable' cannot be const");
if (p_false)
free (p_false);
return;
default:
- message_with_line (elem->lineno,
- "attribute `predicable' must have a constant default");
- errors = 1;
+ error_with_line (elem->lineno,
+ "attribute `predicable' must have a constant default");
if (p_false)
free (p_false);
return;
predicable_default = 0;
else
{
- message_with_line (elem->lineno,
- "unknown value `%s' for `predicable' attribute",
- value);
- errors = 1;
+ error_with_line (elem->lineno,
+ "unknown value `%s' for `predicable' attribute", value);
if (p_false)
free (p_false);
}
if (n_alternatives (c) != 1)
{
- message_with_line (lineno,
- "too many alternatives for operand %d",
- XINT (pattern, 0));
- errors = 1;
+ error_with_line (lineno, "too many alternatives for operand %d",
+ XINT (pattern, 0));
return NULL;
}
if (XVECLEN (ce_elem->data, 0) != 1)
{
- message_with_line (ce_elem->lineno,
- "too many patterns in predicate");
- errors = 1;
+ error_with_line (ce_elem->lineno, "too many patterns in predicate");
return;
}
struct queue_elem *elem;
identify_predicable_attribute ();
- if (errors)
+ if (have_error)
return;
for (elem = define_cond_exec_queue; elem ; elem = elem->next)
condition_table = htab_create (500, hash_c_test, cmp_c_test, NULL);
init_predicate_table ();
obstack_init (rtl_obstack);
- errors = 0;
sequence_num = 0;
no_more_options = false;
already_read_stdin = false;
if (define_cond_exec_queue != NULL)
process_define_cond_exec ();
- return errors ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;
+ return have_error ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;
}
/* Programs that don't have their own options can use this entry point
#include "system.h"
#include "coretypes.h"
#include "hashtab.h"
+#include "errors.h"
#include "read-md.h"
/* Associates PTR (which can be a string, etc.) with the file location
}
}
+/* A vfprintf-like function for reporting an error against line LINENO
+ of the current MD file. */
+
+static void ATTRIBUTE_PRINTF(2,0)
+message_with_line_1 (int lineno, const char *msg, va_list ap)
+{
+ fprintf (stderr, "%s:%d: ", read_md_filename, lineno);
+ vfprintf (stderr, msg, ap);
+ fputc ('\n', stderr);
+}
+
/* A printf-like function for reporting an error against line LINENO
in the current MD file. */
va_list ap;
va_start (ap, msg);
+ message_with_line_1 (lineno, msg, ap);
+ va_end (ap);
+}
- fprintf (stderr, "%s:%d: ", read_md_filename, lineno);
- vfprintf (stderr, msg, ap);
- fputc ('\n', stderr);
+/* Like message_with_line, but treat the condition as an error. */
+
+void
+error_with_line (int lineno, const char *msg, ...)
+{
+ va_list ap;
+ va_start (ap, msg);
+ message_with_line_1 (lineno, msg, ap);
va_end (ap);
+ have_error = 1;
}
/* A printf-like function for reporting an error against the current
extern const char *join_c_conditions (const char *, const char *);
extern void print_c_condition (const char *);
extern void message_with_line (int, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern void error_with_line (int, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void fatal_with_file_and_line (const char *, ...)
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;