This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch to optionally relax paren expression handling




hi folks.


i need the following patch (plus the relevant #define in tc-foo.h) for
a new target i am working on.  the instruction i am trying to assemble
looks like this:

	insn	(a5), d2

the problem is that while assembling an instruction, the parser tests
several wrong instructions before finding the correct instruction.
unfortunately, some of the wrong instructions expect a value as the
first operand on this insn, so when parsing the `(a5)' above, it attempts
to evaluate this as a math grouping, but this fails, and a call to
as_bad() is taken, causing the assemble to fail.  with the following
patch, when RELAX_PAREN_GROUPING is defined, a mis-matched '()' will
not call as_bad().  this fixes my problem and allows the assembler to
find the correct instruction and generate the right output.  i also
have reworked the increment of input_line_pointer and corrected the
as_bad() error message in the '[' case.

note that this is unrelated (but similar) to the patch submitted by
fche recently.


if this is OK, would someone please commit it?


thanks,

.mrg.



2000-06-23  matthew green  <mrg@redhat.com>

        * expr.c (operand): Do not as_bad() if RELAX_PAREN_GROUPING is
	defined.  Fix error message for `[' grouping.

Index: expr.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gas/expr.c,v
retrieving revision 1.124
diff -p -c -r1.124 expr.c
*** expr.c	2000/04/30 17:47:05	1.124
--- expr.c	2000/06/23 07:54:08
*************** operand (expressionP)
*** 1028,1039 ****
        /* didn't begin with digit & not a name */
        segment = expression (expressionP);
        /* Expression() will pass trailing whitespace */
!       if ((c == '(' && *input_line_pointer++ != ')')
! 	  || (c == '[' && *input_line_pointer++ != ']'))
  	{
! 	  as_bad (_("Missing ')' assumed"));
! 	  input_line_pointer--;
  	}
        SKIP_WHITESPACE ();
        /* here with input_line_pointer->char after "(...)" */
        return segment;
--- 1028,1043 ----
        /* didn't begin with digit & not a name */
        segment = expression (expressionP);
        /* Expression() will pass trailing whitespace */
!       if ((c == '(' && *input_line_pointer != ')')
! 	  || (c == '[' && *input_line_pointer != ']'))
  	{
! #ifdef RELAX_PAREN_GROUPING
! 	  if (c != '(')
! #endif
! 	    as_bad (_("Missing '%c' assumed"), c == '(' ? ')' : ']');
  	}
+       else
+         input_line_pointer++;
        SKIP_WHITESPACE ();
        /* here with input_line_pointer->char after "(...)" */
        return segment;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]