aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/cond.c96
-rw-r--r--gas/listing.c10
-rw-r--r--gas/testsuite/ChangeLog5
-rw-r--r--gas/testsuite/gas/all/cond.d20
-rw-r--r--gas/testsuite/gas/all/cond.s14
6 files changed, 93 insertions, 57 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index d73ab69..4d20134 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -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.
diff --git a/gas/cond.c b/gas/cond.c
index 034796b..6c6e8ad 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -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)
{
diff --git a/gas/listing.c b/gas/listing.c
index 96c7239..8168ebe 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -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;
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index f1abc4b..3c218e4 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -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.
diff --git a/gas/testsuite/gas/all/cond.d b/gas/testsuite/gas/all/cond.d
index a496287..4d0da36 100644
--- a/gas/testsuite/gas/all/cond.d
+++ b/gas/testsuite/gas/all/cond.d
@@ -13,8 +13,18 @@
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
diff --git a/gas/testsuite/gas/all/cond.s b/gas/testsuite/gas/all/cond.s
index 3958321..ba4bd6c 100644
--- a/gas/testsuite/gas/all/cond.s
+++ b/gas/testsuite/gas/all/cond.s
@@ -15,4 +15,18 @@
.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