summaryrefslogtreecommitdiff
path: root/gas/cond.c
diff options
context:
space:
mode:
authorTimothy Wall <twall@alum.mit.edu>2000-02-08 14:13:57 +0000
committerTimothy Wall <twall@alum.mit.edu>2000-02-08 14:13:57 +0000
commitcd46f7128cc14f65ae11a94c00df5444d7976013 (patch)
tree810d37df174ee675db27281ad49b359096e8eabc /gas/cond.c
parentdfe3ef3b6c6fc043a981869e07b2f5b3726a1623 (diff)
downloadbinutils-redhat-cd46f7128cc14f65ae11a94c00df5444d7976013.tar.gz
New elseif directive has been added.
Diffstat (limited to 'gas/cond.c')
-rw-r--r--gas/cond.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/gas/cond.c b/gas/cond.c
index 943c9f6bf8..a0e6e41a1b 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -247,6 +247,86 @@ s_ifc (arg)
}
void
+s_elseif (arg)
+ int arg;
+{
+ expressionS operand;
+ int t;
+
+ if (current_cframe == NULL)
+ {
+ as_bad (_("\".elseif\" without matching \".if\" - ignored"));
+
+ }
+ else if (current_cframe->else_seen)
+ {
+ as_bad (_("\".elseif\" after \".else\" - ignored"));
+ as_bad_where (current_cframe->else_file_line.file,
+ current_cframe->else_file_line.line,
+ _("here is the previous \"else\""));
+ as_bad_where (current_cframe->if_file_line.file,
+ current_cframe->if_file_line.line,
+ _("here is the previous \"if\""));
+ }
+ else
+ {
+ 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 */
+
+
+ SKIP_WHITESPACE (); /* Leading whitespace is part of operand. */
+
+ 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)
+ {
+ 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;
+
+ if (LISTING_SKIP_COND ()
+ && current_cframe->ignoring
+ && (current_cframe->previous_cframe == NULL
+ || ! current_cframe->previous_cframe->ignoring))
+ listing_list (2);
+
+ demand_empty_rest_of_line ();
+}
+
+void
s_endif (arg)
int arg ATTRIBUTE_UNUSED;
{