Fix assertion failure when using -Wmacro-redefinition, -y, and -D.

Predefined macros get stored in the precompiled macro file that gets
read back in when processing library files. This means the predefined
macros get processed twice. We need to skip the check in this case.
This commit is contained in:
Martin Whitaker 2017-11-08 20:07:38 +00:00
parent 02daffc97e
commit c0845d8bea
1 changed files with 6 additions and 1 deletions

View File

@ -863,8 +863,13 @@ void define_macro(const char* name, const char* value, int keyword, int argc)
/* 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.
*
* If istack is empty, we are processing a configuration
* or precompiled macro file, so don't want to check for
* redefinitions - when a precompiled macro file is used,
* it will contain copies of any predefined macros.
*/
if (warn_redef) {
if (warn_redef && istack) {
prev = def_lookup(name);
if (prev && (warn_redef_all || (strcmp(prev->value, value) != 0))) {
emit_pathline(istack);