diff --git a/Changes b/Changes index 166ec5437..4445d47ec 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Support const object new() assignments. +**** Support # as a comment in -f files (#2497). [phantom-killua] + * Verilator 4.100 2020-09-07 diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 3b2aabde7..141593820 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -1587,6 +1587,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { string oline; // cppcheck-suppress StlMissingComparison char lastch = ' '; + bool space_begin = true; // At beginning or leading spaces only for (string::const_iterator pos = line.begin(); pos != line.end(); lastch = *pos++) { if (inCmt) { if (*pos == '*' && *(pos + 1) == '/') { @@ -1596,11 +1597,15 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) { } else if (*pos == '/' && *(pos + 1) == '/' && (pos == line.begin() || isspace(lastch))) { // But allow /file//path break; // Ignore to EOL + } else if (*pos == '#' && space_begin) { // Only # at [spaced] begin of line + break; // Ignore to EOL } else if (*pos == '/' && *(pos + 1) == '*') { inCmt = true; + space_begin = false; // cppcheck-suppress StlMissingComparison ++pos; } else { + if (!isspace(*pos)) space_begin = false; oline += *pos; } } diff --git a/test_regress/t/t_flag_f.vc b/test_regress/t/t_flag_f.vc index 44e4076c8..88883245c 100644 --- a/test_regress/t/t_flag_f.vc +++ b/test_regress/t/t_flag_f.vc @@ -1,4 +1,5 @@ // Test that environment substitutions work +# This is also a comment (in several simulators) -f $VERILATOR_ROOT/test_regress/t/t_flag_f__2.vc // Env var with .v file, and parens // Double slash below is intentional, as allowed in other tools