ivlpp: Warn about macro redefinition

Verilog spec has a very nasty system of macros jumping from
file to file, resulting in a global macro scope. We abosolutely
MUST track macro redefinitions and warn user about them.

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
This commit is contained in:
Andrew Andrianov 2017-10-08 14:18:32 +03:00
parent e315cafa01
commit 73167563d5
1 changed files with 13 additions and 0 deletions

View File

@ -858,6 +858,19 @@ void define_macro(const char* name, const char* value, int keyword, int argc)
{
int idx;
struct define_t* def;
struct define_t* prev;
/* Verilog spec has a very nasty system of macros jumping from
* file to file, resulting in a global macro scope. We abosolutely
* MUST track macro redefinitions and warn user about them.
*/
prev = def_lookup(name);
if (prev) {
emit_pathline(istack);
fprintf(stderr, "warning: redefinition of macro %s\n",
name);
}
def = malloc(sizeof(struct define_t));
def->name = strdup(name);