This is the mail archive of the binutils@sources.redhat.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]

Re: Problem with .elseif conditional in binutils-2.10 gas


On Fri, 30 Mar 2001, Michael Schwingen wrote:

> I am having problems with the .elseif conditional in as of binutils 2.10

Fixed, along with a potential abort on invalid input.  Thanks for the
report.

	* cond.c (s_endif): Correct handling of "if .. elseif .." trees.
	Don't abort on NULL current_cframe.

Alan Modra
-- 
Linuxcare

Index: gas/cond.c
===================================================================
RCS file: /cvs/src/src/gas/cond.c,v
retrieving revision 1.8
diff -c -p -r1.8 cond.c
*** cond.c	2001/03/08 23:24:22	1.8
--- cond.c	2001/03/31 01:53:40
*************** struct conditional_frame {
*** 47,53 ****
    int else_seen;
    /* Whether we are currently ignoring input.  */
    int ignoring;
!   /* Whether a conditional at a higher level is ignoring input.  */
    int dead_tree;
    /* Macro nesting level at which this conditional was created.  */
    int macro_nest;
--- 47,55 ----
    int else_seen;
    /* Whether we are currently ignoring input.  */
    int ignoring;
!   /* Whether a conditional at a higher level is ignoring input.
!      Set also when a branch of an "if .. elseif .." tree has matched
!      to prevent further matches.  */
    int dead_tree;
    /* Macro nesting level at which this conditional was created.  */
    int macro_nest;
*************** s_elseif (arg)
*** 259,265 ****
    if (current_cframe == NULL)
      {
        as_bad (_("\".elseif\" without matching \".if\" - ignored"));
- 
      }
    else if (current_cframe->else_seen)
      {
--- 261,266 ----
*************** s_elseif (arg)
*** 278,283 ****
--- 279,285 ----
  
        if (!current_cframe->dead_tree)
  	{
+ 	  current_cframe->dead_tree = !current_cframe->ignoring;
  	  current_cframe->ignoring = !current_cframe->ignoring;
  	  if (LISTING_SKIP_COND ())
  	    {
*************** s_elseif (arg)
*** 288,309 ****
  	    }
  	}			/* if not a dead tree */
      }				/* if error else do it */
- 
-   /* Leading whitespace is part of operand.  */
-   SKIP_WHITESPACE ();
  
!   if (current_cframe != NULL && current_cframe->ignoring)
      {
-       operand.X_add_number = 0;
        while (! is_end_of_line[(unsigned char) *input_line_pointer])
  	++input_line_pointer;
!     }
!   else
!     {
!       expression (&operand);
!       if (operand.X_op != O_constant)
! 	as_bad (_("non-constant expression in \".elseif\" statement"));
      }
  
    switch ((operatorT) arg)
      {
--- 290,309 ----
  	    }
  	}			/* if not a dead tree */
      }				/* if error else do it */
  
!   if (current_cframe == NULL || current_cframe->ignoring)
      {
        while (! is_end_of_line[(unsigned char) *input_line_pointer])
  	++input_line_pointer;
!       return;
      }
+ 
+   /* Leading whitespace is part of operand.  */
+   SKIP_WHITESPACE ();
+ 
+   expression (&operand);
+   if (operand.X_op != O_constant)
+     as_bad (_("non-constant expression in \".elseif\" statement"));
  
    switch ((operatorT) arg)
      {


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