patch: improved gas error messages

Graydon Hoare graydon@redhat.com
Tue May 1 12:33:00 GMT 2001


attached is a patch against cgen and opcodes which improves the error
messages gas emits when encountering a syntax error in the operand of
an overloaded instruction. the previous strategy assumed that a parse
error anywhere after the mnemonic represented a failure to match the
"form" of the instruction, so it would move on to the next overloading
and discard the possibly useful operand error message.

for example, suppose I had an instruction with two forms: 

foo bar, (operand)
foo (operand), (operand)

then a "foo bar" instruction with a syntax error in the operand will
cause the "foo bar" to be skipped as a candidate form of the foo insn,
and the second candidate will be tried. if bar is not a valid operand in
the second form, gas emits an error telling you that it cannot recognize
the insn at all, which is false: it has a perfectly good error message
about what was wrong in the first operand, it just dropped it. there
are instruction sets for which this is a problem, and cannot be fixed
by reordering the candidates.

this patch adds a regex_t to each instruction, which is built from
the instruction syntax description, such that any instruction form not
matching the regex is skipped when trying to resolve an overloading.
this has the effect that an operand syntax error will be preserved if
no other overloading candidates match the regex.

additionally, the matching strategy notices when it has at very least
got the mnemonic right. this allows you to differentiate between 
failure-to-match-syntax and unknown-instruction-mnemonic cases.

I've built it on solaris, cygwin and linux here, and a half-dozen target
gas' pass their tests, so it doesn't seem too disruptive.

comments?

-graydon



More information about the Binutils mailing list