diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index b8ccb6296..a74a8c357 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -860,16 +860,17 @@ void define_macro(const char* name, const char* value, int keyword, int argc) 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. + /* Verilog has a very nasty system of macros jumping from + * file to file, resulting in a global macro scope. Here + * we optionally warn about any redefinitions. */ - - prev = def_lookup(name); - if (prev && warn_redef) { - emit_pathline(istack); - fprintf(stderr, "warning: redefinition of macro %s from value '%s' to '%s'\n", - name, prev->value, value); + if (warn_redef) { + prev = def_lookup(name); + if (prev) { + emit_pathline(istack); + fprintf(stderr, "warning: redefinition of macro %s from value '%s' to '%s'\n", + name, prev->value, value); + } } def = malloc(sizeof(struct define_t));