Fix conditional assembly listings when more than one .else/.elsif
authorAlan Modra <amodra@gmail.com>
Sat, 31 Mar 2001 06:47:54 +0000 (06:47 +0000)
committerAlan Modra <amodra@gmail.com>
Sat, 31 Mar 2001 06:47:54 +0000 (06:47 +0000)
gas/ChangeLog
gas/cond.c
gas/listing.c
gas/testsuite/ChangeLog
gas/testsuite/gas/all/cond.d
gas/testsuite/gas/all/cond.s

index d73ab69d56a61cdff3d1318a7718be9b2f8d4d3e..4d20134f0d77c568d3ac93c68b6c7401ddb09d86 100644 (file)
@@ -1,5 +1,10 @@
 2001-03-31  Alan Modra  <alan@linuxcare.com.au>
 
+       * listing.c (listing_listing): Enable listing on EDICT_NOLIST_NEXT
+       for one line if not already enabled.
+       * cond.c (s_elseif): Correct conditional assembly listing.
+       (s_else): Likewise.
+
        * cond.c (s_endif): Correct handling of "if .. elseif .." trees.
        Don't abort on NULL current_cframe.
 
index 034796b2e3d7f4a05250a1ed5010e5d417d93775..6c6e8adfa388155d5666b0d0acf46baef02bbfe3 100644 (file)
@@ -255,9 +255,6 @@ void
 s_elseif (arg)
      int arg;
 {
-  expressionS operand;
-  int t;
-
   if (current_cframe == NULL)
     {
       as_bad (_("\".elseif\" without matching \".if\" - ignored"));
@@ -277,54 +274,55 @@ s_elseif (arg)
       as_where (&current_cframe->else_file_line.file,
                &current_cframe->else_file_line.line);
 
-      if (!current_cframe->dead_tree)
-       {
-         current_cframe->dead_tree = !current_cframe->ignoring;
-         current_cframe->ignoring = !current_cframe->ignoring;
-         if (LISTING_SKIP_COND ())
-           {
-             if (! current_cframe->ignoring)
-               listing_list (1);
-             else
-               listing_list (2);
-           }
-       }                       /* if not a dead tree */
-    }                          /* if error else do it */
+      current_cframe->dead_tree |= !current_cframe->ignoring;
+      current_cframe->ignoring = current_cframe->dead_tree;
+    }
 
   if (current_cframe == NULL || current_cframe->ignoring)
     {
       while (! is_end_of_line[(unsigned char) *input_line_pointer])
        ++input_line_pointer;
-      return;
+
+      if (current_cframe == NULL)
+       return;
     }
+  else
+    {
+      expressionS operand;
+      int t;
 
-  /* Leading whitespace is part of operand.  */
-  SKIP_WHITESPACE ();
+      /* Leading whitespace is part of operand.  */
+      SKIP_WHITESPACE ();
 
-  expression (&operand);
-  if (operand.X_op != O_constant)
-    as_bad (_("non-constant expression in \".elseif\" statement"));
+      expression (&operand);
+      if (operand.X_op != O_constant)
+       as_bad (_("non-constant expression in \".elseif\" statement"));
 
-  switch ((operatorT) arg)
-    {
-    case O_eq: t = operand.X_add_number == 0; break;
-    case O_ne: t = operand.X_add_number != 0; break;
-    case O_lt: t = operand.X_add_number < 0; break;
-    case O_le: t = operand.X_add_number <= 0; break;
-    case O_ge: t = operand.X_add_number >= 0; break;
-    case O_gt: t = operand.X_add_number > 0; break;
-    default:
-      abort ();
-      return;
-    }
+      switch ((operatorT) arg)
+       {
+       case O_eq: t = operand.X_add_number == 0; break;
+       case O_ne: t = operand.X_add_number != 0; break;
+       case O_lt: t = operand.X_add_number < 0; break;
+       case O_le: t = operand.X_add_number <= 0; break;
+       case O_ge: t = operand.X_add_number >= 0; break;
+       case O_gt: t = operand.X_add_number > 0; break;
+       default:
+         abort ();
+         return;
+       }
 
-  current_cframe->ignoring = current_cframe->dead_tree || ! t;
+      current_cframe->ignoring = current_cframe->dead_tree || ! t;
+    }
 
   if (LISTING_SKIP_COND ()
-      && current_cframe->ignoring
       && (current_cframe->previous_cframe == NULL
          || ! current_cframe->previous_cframe->ignoring))
-    listing_list (2);
+    {
+      if (! current_cframe->ignoring)
+       listing_list (1);
+      else
+       listing_list (2);
+    }
 
   demand_empty_rest_of_line ();
 }
@@ -368,7 +366,6 @@ s_else (arg)
   if (current_cframe == NULL)
     {
       as_bad (_(".else without matching .if - ignored"));
-
     }
   else if (current_cframe->else_seen)
     {
@@ -385,20 +382,21 @@ s_else (arg)
       as_where (&current_cframe->else_file_line.file,
                &current_cframe->else_file_line.line);
 
-      if (!current_cframe->dead_tree)
+      current_cframe->ignoring =
+       current_cframe->dead_tree | !current_cframe->ignoring;
+
+      if (LISTING_SKIP_COND ()
+         && (current_cframe->previous_cframe == NULL
+             || ! current_cframe->previous_cframe->ignoring))
        {
-         current_cframe->ignoring = !current_cframe->ignoring;
-         if (LISTING_SKIP_COND ())
-           {
-             if (! current_cframe->ignoring)
-               listing_list (1);
-             else
-               listing_list (2);
-           }
-       }                       /* if not a dead tree */
+         if (! current_cframe->ignoring)
+           listing_list (1);
+         else
+           listing_list (2);
+       }
 
       current_cframe->else_seen = 1;
-    }                          /* if error else do it */
+    }
 
   if (flag_mri)
     {
index 96c723906e068ffa54308960ed04052b4649078f..8168ebe6b9812d156db1ef46bbca84db60c42704 100644 (file)
@@ -1,5 +1,6 @@
 /* listing.c - mainting assembly listings
-   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2001
    Free Software Foundation, Inc.
 
 This file is part of GAS, the GNU Assembler.
@@ -1007,6 +1008,8 @@ listing_listing (name)
          show_listing--;
          break;
        case EDICT_NOLIST_NEXT:
+         if (show_listing == 0)
+           list_line--;
          break;
        case EDICT_EJECT:
          break;
@@ -1029,7 +1032,8 @@ listing_listing (name)
            p = buffer_line (list->file, buffer, width);
        }
 
-      if (list->edict == EDICT_LIST)
+      if (list->edict == EDICT_LIST
+         || (list->edict == EDICT_NOLIST_NEXT && show_listing == 0))
        {
          /* Enable listing for the single line that caused the enable.  */
          list_line++;
@@ -1090,7 +1094,7 @@ listing_listing (name)
            }
        }
 
-      if (list->edict == EDICT_NOLIST_NEXT)
+      if (list->edict == EDICT_NOLIST_NEXT && show_listing == 1)
        --show_listing;
 
       list = list->next;
index f1abc4b772e46e9940a501a047e243649140ac4e..3c218e4fe47aa169a230fddc73ff2cf42a636a47 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-31  Alan Modra  <alan@linuxcare.com.au>
+
+       * gas/all/cond.s: Add .if .elseif tree.
+       * gas/all/cond.d: Match above.
+
 2001-03-30  H.J. Lu  <hjl@gnu.org>
 
        * gas/i386/relax.d: Dump with -s instead of -drw.
index a496287916cbb51305419a32477c88d02652fe06..4d0da366f7f8f5a027ec21799fdb3b7c0764db97 100644 (file)
   15 0004 0[04] ?00 ?00 ?0[04][        ]+.long[        ]+4
   16[  ]+.endc
   17[  ]+.endc
-  18 0008 00 ?00 ?00 ?00[      ]+.p2align 5,0
-  18[  ]+00 ?00 ?00 ?00 
-  18[  ]+00 ?00 ?00 ?00 
-  18[  ]+00 ?00 ?00 ?00 
-  18[  ]+00 ?00 ?00 ?00 
+  18[  ]+
+  19[  ]+.if   0
+  21[  ]+.elseif       1
+  22[  ]+.if   0
+  24[  ]+.elseif       1
+  25 0008 0[07] ?00 ?00 ?0[07][        ]+.long[        ]+7
+  26[  ]+.endif
+  27[  ]+.elseif       1
+  29[  ]+.else
+  31[  ]+.endif
+  32 000c 00 ?00 ?00 ?00[      ]+.p2align 5,0
+  32[  ]+00 ?00 ?00 ?00 
+  32[  ]+00 ?00 ?00 ?00 
+  32[  ]+00 ?00 ?00 ?00 
+  32[  ]+00 ?00 ?00 ?00 
index 39583211e6fec0d5bda64b52e9f121241bd2c230..ba4bd6ca612aca66473b0647055b61984142f528 100644 (file)
        .long   4
        .endc
        .endc
+
+       .if     0
+       .long   5
+       .elseif 1
+       .if     0
+       .long   6
+       .elseif 1
+       .long   7
+       .endif
+       .elseif 1
+       .long   8
+       .else
+       .long   9
+       .endif
        .p2align 5,0