Makefile.in (build/read-md.o): Depend on errors.h.

gcc/
	* 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.

From-SVN: r160573
This commit is contained in:
Richard Sandiford 2010-06-10 20:21:59 +00:00 committed by Richard Sandiford
parent c5e88b399c
commit bb933490c3
9 changed files with 221 additions and 295 deletions

View File

@ -1,3 +1,27 @@
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.

View File

@ -3775,7 +3775,7 @@ build/min-insn-modes.o : min-insn-modes.c $(BCONFIG_H) $(SYSTEM_H) \
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

View File

@ -886,19 +886,17 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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;
@ -913,10 +911,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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;
@ -928,12 +925,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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:
@ -951,10 +945,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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. */
@ -977,9 +970,8 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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;
}
@ -999,27 +991,18 @@ check_attr_value (rtx exp, struct attr_desc *attr)
{
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;
@ -1030,10 +1013,9 @@ check_attr_value (rtx exp, struct attr_desc *attr)
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;
}
@ -1052,9 +1034,8 @@ convert_set_attr_alternative (rtx exp, struct insn_def *id)
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;
}
@ -1133,8 +1114,7 @@ check_defs (void)
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;
@ -1148,9 +1128,8 @@ check_defs (void)
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)
@ -1158,9 +1137,8 @@ check_defs (void)
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;
}
@ -2937,10 +2915,9 @@ gen_attr (rtx exp, int lineno)
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;
@ -2966,22 +2943,15 @@ gen_attr (rtx exp, int 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);
@ -3115,9 +3085,9 @@ gen_delay (rtx def, int lineno)
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;
}

View File

@ -446,17 +446,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
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);
@ -475,17 +469,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
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);
@ -505,17 +493,11 @@ scan_operands (struct data *d, rtx part, int this_address_p,
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);
@ -717,11 +699,8 @@ process_template (struct data *d, const char *template_code)
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");
}
@ -770,11 +749,11 @@ validate_insn_alternatives (struct data *d)
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
@ -787,30 +766,28 @@ validate_insn_alternatives (struct data *d)
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;
}
}
@ -827,10 +804,7 @@ validate_insn_operands (struct data *d)
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
@ -1148,13 +1122,12 @@ note_constraint (rtx exp, int lineno)
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;
}
@ -1171,25 +1144,22 @@ note_constraint (rtx exp, int lineno)
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;
}
}
@ -1217,11 +1187,10 @@ mdep_constraint_len (const char *s, int lineno, int opno)
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 */
}

View File

@ -67,9 +67,8 @@ validate_exp (rtx exp, const char *name, int lineno)
{
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;
}
}
@ -82,10 +81,9 @@ validate_exp (rtx exp, const char *name, int lineno)
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;
}
}
@ -119,10 +117,9 @@ process_define_predicate (rtx defn, int lineno)
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;
}
@ -765,12 +762,11 @@ add_constraint (const char *name, const char *regclass,
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++)
@ -780,11 +776,10 @@ add_constraint (const char *name, const char *regclass,
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;
}
}
@ -792,13 +787,12 @@ add_constraint (const char *name, const char *regclass,
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;
}
@ -817,25 +811,22 @@ add_constraint (const char *name, const char *regclass,
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;
}
}
@ -856,43 +847,36 @@ add_constraint (const char *name, const char *regclass,
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;
}
}

View File

@ -170,9 +170,6 @@ static int max_depth;
/* The line number of the start of the pattern currently being processed. */
static int pattern_lineno;
/* Count of errors. */
static int error_count;
/* Predicate handling.
@ -289,8 +286,7 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
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;
}
@ -309,9 +305,9 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
}
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'
@ -333,10 +329,9 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
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++)
@ -351,10 +346,9 @@ compute_predicate_codes (rtx exp, char codes[NUM_RTX_CODE])
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;
}
@ -634,12 +628,9 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
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:
@ -695,20 +686,14 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
&& find_matching_operand (insn, XINT (pattern, 0)))
;
else
{
message_with_line (pattern_lineno,
"operand %d missing in-out reload",
XINT (pattern, 0));
error_count++;
}
error_with_line (pattern_lineno,
"operand %d missing in-out reload",
XINT (pattern, 0));
}
else if (constraints0 != '=' && constraints0 != '+')
{
message_with_line (pattern_lineno,
"operand %d missing output reload",
XINT (pattern, 0));
error_count++;
}
error_with_line (pattern_lineno,
"operand %d missing output reload",
XINT (pattern, 0));
}
}
@ -782,12 +767,9 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
/* 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. */
@ -828,12 +810,9 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code)
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:
@ -1494,12 +1473,11 @@ merge_accept_insn (struct decision *oldd, struct decision *addd)
}
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++;
}
}
@ -2771,7 +2749,7 @@ main (int argc, char **argv)
}
}
if (error_count || have_error)
if (have_error)
return FATAL_EXIT_CODE;
puts ("\n\n");

View File

@ -45,7 +45,6 @@ static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
static int sequence_num;
static int errors;
static int predicable_default;
static const char *predicable_true;
@ -222,8 +221,7 @@ process_include (rtx desc, int lineno)
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:
@ -369,9 +367,8 @@ is_predicable (struct queue_elem *elem)
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;
@ -390,9 +387,8 @@ is_predicable (struct queue_elem *elem)
/* ??? 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:
@ -409,9 +405,7 @@ is_predicable (struct queue_elem *elem)
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;
}
@ -421,10 +415,8 @@ is_predicable (struct queue_elem *elem)
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;
}
@ -443,9 +435,8 @@ identify_predicable_attribute (void)
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:
@ -454,9 +445,7 @@ identify_predicable_attribute (void)
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;
@ -473,17 +462,14 @@ identify_predicable_attribute (void)
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;
@ -495,10 +481,8 @@ identify_predicable_attribute (void)
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);
}
@ -592,10 +576,8 @@ alter_predicate_for_insn (rtx pattern, int alt, int max_op, int lineno)
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;
}
@ -783,9 +765,7 @@ process_one_cond_exec (struct queue_elem *ce_elem)
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;
}
@ -882,7 +862,7 @@ process_define_cond_exec (void)
struct queue_elem *elem;
identify_predicable_attribute ();
if (errors)
if (have_error)
return;
for (elem = define_cond_exec_queue; elem ; elem = elem->next)
@ -972,7 +952,6 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
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;
@ -1052,7 +1031,7 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
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

View File

@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
#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
@ -174,6 +175,17 @@ print_c_condition (const char *cond)
}
}
/* 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. */
@ -183,14 +195,23 @@ message_with_line (int lineno, const char *msg, ...)
va_list ap;
va_start (ap, msg);
fprintf (stderr, "%s:%d: ", read_md_filename, lineno);
vfprintf (stderr, msg, ap);
fputc ('\n', stderr);
message_with_line_1 (lineno, msg, ap);
va_end (ap);
}
/* 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
position in the MD file. */

View File

@ -47,6 +47,7 @@ extern void print_md_ptr_loc (const void *);
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;