Fix conditional assembly listings when more than one .else/.elsif

This commit is contained in:
Alan Modra 2001-03-31 06:47:54 +00:00
parent 69e37bf6a2
commit 61b96bb428
6 changed files with 95 additions and 59 deletions

View 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.

View 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;
}
/* 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)
else
{
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;
}
expressionS operand;
int t;
current_cframe->ignoring = current_cframe->dead_tree || ! 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;
}
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)
{

View 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;

View 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.

View file

@ -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

View file

@ -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