* config/tc-ia64.c: Fix formatting.
[deliverable/binutils-gdb.git] / gas / cond.c
index 88ab0d25dfd77e94d9493f30489249fe98a71253..73304cbcbd5247ff7c1400c442b91a2eba674037 100644 (file)
@@ -1,5 +1,5 @@
 /* cond.c - conditional assembly pseudo-ops, and .include
-   Copyright (C) 1990, 91, 92, 93, 95, 96, 97, 98, 99, 2000
+   Copyright 1990, 1991, 1992, 1993, 1995, 1997, 1998, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -28,8 +28,7 @@
    scanned.  */
 struct obstack cond_obstack;
 
-struct file_line
-{
+struct file_line {
   char *file;
   unsigned int line;
 };
@@ -37,8 +36,7 @@ struct file_line
 /* We push one of these structures for each .if, and pop it at the
    .endif.  */
 
-struct conditional_frame
-{
+struct conditional_frame {
   /* The source file & line number of the "if".  */
   struct file_line if_file_line;
   /* The source file & line of the "else".  */
@@ -49,7 +47,9 @@ struct conditional_frame
   int else_seen;
   /* Whether we are currently ignoring input.  */
   int ignoring;
-  /* Whether a conditional at a higher level is ignoring input.  */
+  /* 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;
@@ -255,17 +255,13 @@ void
 s_elseif (arg)
      int arg;
 {
-  expressionS operand;
-  int t;
-
   if (current_cframe == NULL)
     {
-      as_bad (_("\".elseif\" without matching \".if\" - ignored"));
-
+      as_bad (_("\".elseif\" without matching \".if\""));
     }
   else if (current_cframe->else_seen)
     {
-      as_bad (_("\".elseif\" after \".else\" - ignored"));
+      as_bad (_("\".elseif\" after \".else\""));
       as_bad_where (current_cframe->else_file_line.file,
                    current_cframe->else_file_line.line,
                    _("here is the previous \"else\""));
@@ -278,55 +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->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 */
-
-  /* Leading whitespace is part of operand.  */
-  SKIP_WHITESPACE ();
+      current_cframe->dead_tree |= !current_cframe->ignoring;
+      current_cframe->ignoring = current_cframe->dead_tree;
+    }
 
-  if (current_cframe != NULL && current_cframe->ignoring)
+  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;
+
+      if (current_cframe == NULL)
+       return;
     }
   else
     {
+      expressionS operand;
+      int t;
+
+      /* 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)
-    {
-    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 ();
 }
@@ -369,12 +365,11 @@ s_else (arg)
 {
   if (current_cframe == NULL)
     {
-      as_bad (_(".else without matching .if - ignored"));
-
+      as_bad (_("\".else\" without matching \".if\""));
     }
   else if (current_cframe->else_seen)
     {
-      as_bad (_("duplicate \"else\" - ignored"));
+      as_bad (_("duplicate \"else\""));
       as_bad_where (current_cframe->else_file_line.file,
                    current_cframe->else_file_line.line,
                    _("here is the previous \"else\""));
@@ -387,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)
     {
This page took 0.027028 seconds and 4 git commands to generate.