From: Michael Urman Date: Wed, 13 Jun 2001 05:56:06 +0000 (-0000) Subject: Added error for duplicate definitions of labels. X-Git-Tag: v0.1.0~458 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18e368c82e7af9fb8415d43899126dadbe380609;p=yasm Added error for duplicate definitions of labels. Changed strdup to y_strdup (ANSI compatibility). svn path=/trunk/yasm/; revision=53 --- diff --git a/include/errwarn.h b/include/errwarn.h index bad9abbd..c17599d3 100644 --- a/include/errwarn.h +++ b/include/errwarn.h @@ -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 *, ...); diff --git a/libyasm/errwarn.c b/libyasm/errwarn.c index b2db9048..cc2fe98a 100644 --- a/libyasm/errwarn.c +++ b/libyasm/errwarn.c @@ -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); } diff --git a/libyasm/errwarn.h b/libyasm/errwarn.h index bad9abbd..c17599d3 100644 --- a/libyasm/errwarn.h +++ b/libyasm/errwarn.h @@ -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 *, ...); diff --git a/libyasm/symrec.c b/libyasm/symrec.c index 12a7ba46..70637c98 100644 --- a/libyasm/symrec.c +++ b/libyasm/symrec.c @@ -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); } diff --git a/src/errwarn.c b/src/errwarn.c index b2db9048..cc2fe98a 100644 --- a/src/errwarn.c +++ b/src/errwarn.c @@ -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); } diff --git a/src/errwarn.h b/src/errwarn.h index bad9abbd..c17599d3 100644 --- a/src/errwarn.h +++ b/src/errwarn.h @@ -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 *, ...); diff --git a/src/symrec.c b/src/symrec.c index 12a7ba46..70637c98 100644 --- a/src/symrec.c +++ b/src/symrec.c @@ -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); }