From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graydon Hoare To: cgen@sources.redhat.com, binutils@sources.redhat.com Subject: patch: improved gas error messages Date: Tue, 01 May 2001 12:33:00 -0000 Message-id: <20010501153328.D7920@tomago.toronto.redhat.com> X-SW-Source: 2001-q2/msg00029.html 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