diff --git a/ivlpp/globals.h b/ivlpp/globals.h index 90b4632b9..1c4cee43d 100644 --- a/ivlpp/globals.h +++ b/ivlpp/globals.h @@ -53,6 +53,8 @@ extern char dep_mode; extern int verbose_flag; +extern int warn_redef; + /* This is the entry to the lexer. */ extern int yylex(void); diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index a0aa71b42..c03057d65 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -868,8 +868,8 @@ void define_macro(const char* name, const char* value, int keyword, int argc) prev = def_lookup(name); if (prev) { emit_pathline(istack); - fprintf(stderr, "warning: redefinition of macro %s\n", - name); + fprintf(stderr, "warning: redefinition of macro %s from value '%s' to '%s'\n", + name, prev->value, value); } def = malloc(sizeof(struct define_t)); diff --git a/ivlpp/main.c b/ivlpp/main.c index 7ec80cb86..b4909b647 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -98,6 +98,9 @@ int line_direct_flag = 0; unsigned error_count = 0; FILE *depend_file = NULL; +/* Should we warn about macro redefinitions? */ +int warn_redef = 0; + static int flist_read_flags(const char*path) { char line_buf[2048]; @@ -282,7 +285,7 @@ int main(int argc, char*argv[]) include_dir[0] = 0; /* 0 is reserved for the current files path. */ include_dir[1] = strdup("."); - while ((opt=getopt(argc, argv, "F:f:K:Lo:p:P:vV")) != EOF) switch (opt) { + while ((opt=getopt(argc, argv, "F:f:K:Lo:p:P:vVW:")) != EOF) switch (opt) { case 'F': flist_read_flags(optarg); @@ -336,6 +339,12 @@ int main(int argc, char*argv[]) break; } + case 'W': { + if (strcmp(optarg, "redef")==0) + warn_redef = 1; + break; + } + case 'v': fprintf(stderr, "Icarus Verilog Preprocessor version " VERSION " (" VERSION_TAG ")\n\n"); @@ -366,7 +375,8 @@ int main(int argc, char*argv[]) " -p - Write precompiled defines to \n" " -P - Read precompiled defines from \n" " -v - Verbose\n" - " -V - Print version information and quit\n", + " -V - Print version information and quit\n" + " -W - Enable extra ivlpp warning category (e.g. redef)\n", argv[0]); return flag_errors; }