]> granicus.if.org Git - yasm/commitdiff
Added error for duplicate definitions of labels.
authorMichael Urman <mu@tortall.net>
Wed, 13 Jun 2001 05:56:06 +0000 (05:56 -0000)
committerMichael Urman <mu@tortall.net>
Wed, 13 Jun 2001 05:56:06 +0000 (05:56 -0000)
Changed strdup to y_strdup (ANSI compatibility).

svn path=/trunk/yasm/; revision=53

include/errwarn.h
libyasm/errwarn.c
libyasm/errwarn.h
libyasm/symrec.c
src/errwarn.c
src/errwarn.h
src/symrec.c

index bad9abbd5dac96842d6761ada29b7e8369a6d661..c17599d329f8d69045b7e336f4b4aa34b0fc3bcc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.5 2001/06/13 05:43:59 mu Exp $
+/* $Id: errwarn.h,v 1.6 2001/06/13 05:56:06 mu Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -39,7 +39,8 @@ typedef enum {
     ERR_INVALID_ARG,
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
-    ERR_EXP_SYNTAX
+    ERR_EXP_SYNTAX,
+    ERR_DUPLICATE_DEF
 } err_num;
 
 void Error(err_num, char *, ...);
index b2db90484374862708e17c194f56355508e19b58..cc2fe98aacb6023dbbb17dec1801861899543ddf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.7 2001/06/13 05:53:25 peter Exp $
+/* $Id: errwarn.c,v 1.8 2001/06/13 05:56:06 mu Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -43,7 +43,8 @@ static char *err_msgs[] = {
     "invalid argument to %s",
     "invalid effective address",
     "label or instruction expected at start of line",
-    "expression syntax error"
+    "expression syntax error",
+    "duplicate definition of `%s'; previously defined line %d"
 };
 
 static char *warn_msgs[] = {
@@ -130,7 +131,7 @@ static char *process_argtypes(char *src, char *argtypes)
            }
        }
     } else {
-       dest = strdup(src);
+       dest = y_strdup(src);
        if(!dest)
            Fatal(FATAL_NOMEM);
     }
index bad9abbd5dac96842d6761ada29b7e8369a6d661..c17599d329f8d69045b7e336f4b4aa34b0fc3bcc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.5 2001/06/13 05:43:59 mu Exp $
+/* $Id: errwarn.h,v 1.6 2001/06/13 05:56:06 mu Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -39,7 +39,8 @@ typedef enum {
     ERR_INVALID_ARG,
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
-    ERR_EXP_SYNTAX
+    ERR_EXP_SYNTAX,
+    ERR_DUPLICATE_DEF
 } err_num;
 
 void Error(err_num, char *, ...);
index 12a7ba462cfdac4e72befd5a265a8f1e69d66d05..70637c981ca155085d1dee2b2cdd607a1ff6cbdf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: symrec.c,v 1.2 2001/06/13 05:43:59 mu Exp $
+/* $Id: symrec.c,v 1.3 2001/06/13 05:56:06 mu Exp $
  * Symbol table handling
  *
  *  Copyright (C) 2001  Michael Urman
@@ -116,6 +116,8 @@ symrec *sym_def_get (char *name, SymType type)
 {
     symtab *tab;
     tab = symtab_get_or_new (name, type);
+    if (tab->rec.status & SYM_DECLARED)
+       Error (ERR_DUPLICATE_DEF, (char *)NULL, tab->rec.name, tab->rec.line);
     tab->rec.status |= SYM_DECLARED;
     return &(tab->rec);
 }
index b2db90484374862708e17c194f56355508e19b58..cc2fe98aacb6023dbbb17dec1801861899543ddf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.7 2001/06/13 05:53:25 peter Exp $
+/* $Id: errwarn.c,v 1.8 2001/06/13 05:56:06 mu Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -43,7 +43,8 @@ static char *err_msgs[] = {
     "invalid argument to %s",
     "invalid effective address",
     "label or instruction expected at start of line",
-    "expression syntax error"
+    "expression syntax error",
+    "duplicate definition of `%s'; previously defined line %d"
 };
 
 static char *warn_msgs[] = {
@@ -130,7 +131,7 @@ static char *process_argtypes(char *src, char *argtypes)
            }
        }
     } else {
-       dest = strdup(src);
+       dest = y_strdup(src);
        if(!dest)
            Fatal(FATAL_NOMEM);
     }
index bad9abbd5dac96842d6761ada29b7e8369a6d661..c17599d329f8d69045b7e336f4b4aa34b0fc3bcc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.5 2001/06/13 05:43:59 mu Exp $
+/* $Id: errwarn.h,v 1.6 2001/06/13 05:56:06 mu Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -39,7 +39,8 @@ typedef enum {
     ERR_INVALID_ARG,
     ERR_INVALID_EA,
     ERR_INVALID_LINE,
-    ERR_EXP_SYNTAX
+    ERR_EXP_SYNTAX,
+    ERR_DUPLICATE_DEF
 } err_num;
 
 void Error(err_num, char *, ...);
index 12a7ba462cfdac4e72befd5a265a8f1e69d66d05..70637c981ca155085d1dee2b2cdd607a1ff6cbdf 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: symrec.c,v 1.2 2001/06/13 05:43:59 mu Exp $
+/* $Id: symrec.c,v 1.3 2001/06/13 05:56:06 mu Exp $
  * Symbol table handling
  *
  *  Copyright (C) 2001  Michael Urman
@@ -116,6 +116,8 @@ symrec *sym_def_get (char *name, SymType type)
 {
     symtab *tab;
     tab = symtab_get_or_new (name, type);
+    if (tab->rec.status & SYM_DECLARED)
+       Error (ERR_DUPLICATE_DEF, (char *)NULL, tab->rec.name, tab->rec.line);
     tab->rec.status |= SYM_DECLARED;
     return &(tab->rec);
 }