diff --git a/Changes b/Changes index e14145ec9..20017430a 100644 --- a/Changes +++ b/Changes @@ -24,6 +24,7 @@ Verilator 4.213 devel * Fix cygwin compile error due to missing -std=gnu++14 (#3149). [Sun Kim] * Fix missing install of vl_file_copy/vl_hier_graph (#3165). [Popolon] * Fix calling new with arguments in same class (#3166). [Matthew Ballance] +* Fix false EOFNEWLINE warning when DOS carriage returns present (#3171). Verilator 4.212 2021-09-01 diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 02dbeeaa4..c3a43f880 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -824,9 +824,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam for (const char* cp = sp; cp < ep; cp++) { if (VL_UNLIKELY(*cp == '\r' || *cp == '\0')) { strip = true; - break; - } - if (VL_UNLIKELY(*cp == '\n')) { + } else if (VL_UNLIKELY(*cp == '\n')) { eof_newline = 0; ++eof_lineno; } else { @@ -853,7 +851,7 @@ void V3PreProcImp::openFile(FileLine*, VInFilter* filterp, const string& filenam FileLine* fl = new FileLine{flsp}; fl->contentLineno(eof_lineno); fl->column(eof_newline + 1, eof_newline + 1); - fl->v3warn(EOFNEWLINE, "Missing newline at end of file (POSIX 3.206)." + fl->v3warn(EOFNEWLINE, "Missing newline at end of file (POSIX 3.206).\n" << fl->warnMore() << "... Suggest add newline."); } } diff --git a/test_regress/t/t_dos.pl b/test_regress/t/t_dos.pl index b46d46042..f2ebe7037 100755 --- a/test_regress/t/t_dos.pl +++ b/test_regress/t/t_dos.pl @@ -11,6 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di scenarios(simulator => 1); compile( + verilator_flags2 => ['-Wall -Wno-DECLFILENAME'], # To check EOFNEWLINE with DOS CRs ); execute( diff --git a/test_regress/t/t_lint_eofline_bad.out b/test_regress/t/t_lint_eofline_bad.out index 6d20a0dc1..cc52c6298 100644 --- a/test_regress/t/t_lint_eofline_bad.out +++ b/test_regress/t/t_lint_eofline_bad.out @@ -1,4 +1,5 @@ -%Warning-EOFNEWLINE: obj_vlt/t_lint_eofline_bad/t_lint_eofline_bad.v:4:10: Missing newline at end of file (POSIX 3.206). : ... Suggest add newline. +%Warning-EOFNEWLINE: obj_vlt/t_lint_eofline_bad/t_lint_eofline_bad.v:4:10: Missing newline at end of file (POSIX 3.206). + : ... Suggest add newline. 4 | endmodule | ^ ... For warning description see https://verilator.org/warn/EOFNEWLINE?v=latest