This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][Z80] disallow redefining constants with equ


Hello,

The patch below makes gas for target Z80 disallow redefining 
symbols with equ. It also includes a fix for a typo in the 
documentation.

Arnold Metselaar

Changelog

gas/
*config/tc-z80.c(z80_start_line_hook): issue an error when 
redefining a symbol with equ
*doc/as.texinfo(equ<z80>): mention difference with .equiv
*doc/as.texinfo(err): fix typo
*doc/c-z80.texi(equ): redefining a symbol with equ is no longer 
allowed
Index: gas/config/tc-z80.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-z80.c,v
retrieving revision 1.1
diff -u -p -r1.1 tc-z80.c
--- gas/config/tc-z80.c	25 Oct 2005 17:40:17 -0000	1.1
+++ gas/config/tc-z80.c	14 Nov 2005 12:26:30 -0000
@@ -267,6 +267,7 @@ z80_start_line_hook (void)
     {
       char c, *rest, *line_start;
       int len;
+      symbolS * symbolP;
 
       line_start = input_line_pointer;
       LISTING_NEWLINE ();
@@ -293,10 +294,14 @@ z80_start_line_hook (void)
 	  if (line_start[-1] == '\n')
 	    bump_line_counters ();
 	  /* Most Z80 assemblers require the first definition of a
-             label to use "EQU" and redefinitions to have "DEFL".
-             That does not fit the way GNU as deals with labels, so
-             GNU as is more permissive.  */
-	  equals (line_start, TRUE);
+             label to use "EQU" and redefinitions to have "DEFL".  */
+	  if (len == 3 && (symbolP = symbol_find (line_start)) != NULL) 
+	    {
+	      if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
+		as_bad (_("symbol `%s' is already defined"), line_start);
+	    }
+	  /* All symbols may be redefined.  */
+	  equals (line_start, 1);
 	  return 1;
 	}
       else
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.138
diff -u -p -r1.138 as.texinfo
--- gas/doc/as.texinfo	7 Nov 2005 18:07:12 -0000	1.138
+++ gas/doc/as.texinfo	14 Nov 2005 12:26:37 -0000
@@ -4324,6 +4324,7 @@ The syntax for @code{equ} on the HPPA is
 The syntax for @code{equ} on the Z80 is 
 @samp{@var{symbol} equ @var{expression}}. 
 On the Z80 it is an eror if @var{symbol} is already defined,
+but the symbol is not protected from later redefinition, 
 compare @xref{Equiv}.
 @end ifset
 
@@ -4357,7 +4358,7 @@ value is taken.
 @cindex @code{err} directive
 If @command{@value{AS}} assembles a @code{.err} directive, it will print an error
 message and, unless the @option{-Z} option was used, it will not generate an
-object file.  This can be used to signal error an conditionally compiled code.
+object file.  This can be used to signal an error in conditionally compiled code.
 
 @node Error
 @section @code{.error "@var{string}"}
Index: gas/doc/c-z80.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/c-z80.texi,v
retrieving revision 1.1
diff -u -p -r1.1 c-z80.texi
--- gas/doc/c-z80.texi	25 Oct 2005 17:40:18 -0000	1.1
+++ gas/doc/c-z80.texi	14 Nov 2005 12:31:40 -0000
@@ -7,7 +7,6 @@
 @chapter Z80 Dependent Features
 @end ifset
 
-@c DO-NOT-COMMIT
 
 @ifclear GENERIC
 @node Machine Dependencies
@@ -168,9 +167,9 @@ Fill @var{count} bytes in the object fil
 
 @item @var{symbol} equ @var{expression}
 @itemx @var{symbol} defl @var{expression}
-These directives set the value of @var{symbol} to @var{expression}.  To
-keep code portable to other assemblers it is best to use @samp{equ} for
-the first definition and @samp{defl} for redefinitions.
+These directives set the value of @var{symbol} to @var{expression}. If
+@code{equ} is used, it is an error if @var{symbol} is already defined.
+Symbols defined with @code{equ} are not protected from redefinition.
 
 @item set
 This is a normal instruction on Z80, and not an assembler directive. 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]