diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index e14de4c60..85a9d7b83 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -481,17 +481,21 @@ void V3PreProcImp::comment(const string& text) { if ((cp[0] == 'v' || cp[0] == 'V') && VString::startsWith(cp + 1, "erilator")) { cp += std::strlen("verilator"); if (*cp == '_') { - fileline()->v3error("Extra underscore in meta-comment;" - " use /*verilator {...}*/ not /*verilator_{...}*/"); + V3Control::applyIgnores(fileline()); + fileline()->v3warn(BADVLTPRAGMA, "Extra underscore in meta-comment, ignoring comment;" + " use /*verilator {...}*/ not /*verilator_{...}*/"); + return; } vlcomment = true; } else if (VString::startsWith(cp, "synopsys")) { cp += std::strlen("synopsys"); - synth = true; if (*cp == '_') { - fileline()->v3error("Extra underscore in meta-comment;" - " use /*synopsys {...}*/ not /*synopsys_{...}*/"); + V3Control::applyIgnores(fileline()); + fileline()->v3warn(BADVLTPRAGMA, "Extra underscore in meta-comment, ignoring comment;" + " use /*synopsys {...}*/ not /*synopsys_{...}*/"); + return; } + synth = true; } else if (VString::startsWith(cp, "cadence")) { cp += std::strlen("cadence"); synth = true; @@ -505,8 +509,6 @@ void V3PreProcImp::comment(const string& text) { return; } - if (!vlcomment && !synth) return; // Short-circuit - while (std::isspace(*cp)) ++cp; string cmd = commentCleanup(string{cp}); // cmd now is comment without extra spaces and "verilator" prefix diff --git a/test_regress/t/t_pp_underline.py b/test_regress/t/t_pp_underline.py new file mode 100755 index 000000000..6ea49d226 --- /dev/null +++ b/test_regress/t/t_pp_underline.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of either the GNU Lesser General Public License Version 3 +# or the Perl Artistic License Version 2.0. +# SPDX-FileCopyrightText: 2026 Wilson Snyder +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +import vltest_bootstrap + +test.scenarios('vlt') + +test.top_filename = "t/t_pp_underline_bad.v" + +test.lint(verilator_flags2=["-Wno-BADVLTPRAGMA"]) + +test.passes() diff --git a/test_regress/t/t_pp_underline_bad.out b/test_regress/t/t_pp_underline_bad.out index 663d52e91..977a7a361 100644 --- a/test_regress/t/t_pp_underline_bad.out +++ b/test_regress/t/t_pp_underline_bad.out @@ -1,12 +1,8 @@ -%Error: t/t_pp_underline_bad.v:8:4: Extra underscore in meta-comment; use /*verilator {...}*/ not /*verilator_{...}*/ +%Error-BADVLTPRAGMA: t/t_pp_underline_bad.v:8:4: Extra underscore in meta-comment, ignoring comment; use /*verilator {...}*/ not /*verilator_{...}*/ 8 | // verilator_no_inline_module | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance. -%Error: t/t_pp_underline_bad.v:10:19: Extra underscore in meta-comment; use /*synopsys {...}*/ not /*synopsys_{...}*/ + ... For error description see https://verilator.org/warn/BADVLTPRAGMA?v=latest +%Error-BADVLTPRAGMA: t/t_pp_underline_bad.v:10:19: Extra underscore in meta-comment, ignoring comment; use /*synopsys {...}*/ not /*synopsys_{...}*/ 10 | case (1'b1) // synopsys_full_case | ^~~~~~~~~~~~~~~~~~~~~ -%Error-BADVLTPRAGMA: t/t_pp_underline_bad.v:8:4: Unknown verilator comment: '/*verilator _no_inline_module*/' - 8 | /*verilator _no_inline_module*/ - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ... For error description see https://verilator.org/warn/BADVLTPRAGMA?v=latest %Error: Exiting due to diff --git a/test_regress/t/t_pp_underline_bad.v b/test_regress/t/t_pp_underline_bad.v index c5396a1e7..56a87c969 100644 --- a/test_regress/t/t_pp_underline_bad.v +++ b/test_regress/t/t_pp_underline_bad.v @@ -9,6 +9,7 @@ module t; initial begin case (1'b1) // synopsys_full_case 1'b0: $stop; + 1'b1: $finish; endcase $stop; // Should have failed end diff --git a/test_regress/t/t_pp_underline_bad_vlt.out b/test_regress/t/t_pp_underline_bad_vlt.out new file mode 100644 index 000000000..89ac5c94b --- /dev/null +++ b/test_regress/t/t_pp_underline_bad_vlt.out @@ -0,0 +1,5 @@ +%Error-BADVLTPRAGMA: t/t_pp_underline_bad.v:8:4: Extra underscore in meta-comment, ignoring comment; use /*verilator {...}*/ not /*verilator_{...}*/ + 8 | // verilator_no_inline_module + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ... For error description see https://verilator.org/warn/BADVLTPRAGMA?v=latest +%Error: Exiting due to diff --git a/test_regress/t/t_pp_underline_bad_vlt.py b/test_regress/t/t_pp_underline_bad_vlt.py new file mode 100755 index 000000000..46c7f2a76 --- /dev/null +++ b/test_regress/t/t_pp_underline_bad_vlt.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of either the GNU Lesser General Public License Version 3 +# or the Perl Artistic License Version 2.0. +# SPDX-FileCopyrightText: 2026 Wilson Snyder +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +import vltest_bootstrap + +test.scenarios('vlt') + +test.top_filename = "t/t_pp_underline_bad.v" + +test.lint(verilator_flags2=["t/t_pp_underline_bad_vlt.vlt"], + fails=True, + expect_filename=test.golden_filename) + +test.passes() diff --git a/test_regress/t/t_pp_underline_bad_vlt.vlt b/test_regress/t/t_pp_underline_bad_vlt.vlt new file mode 100644 index 000000000..6ac64238f --- /dev/null +++ b/test_regress/t/t_pp_underline_bad_vlt.vlt @@ -0,0 +1,9 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed under the Creative Commons Public Domain. +// SPDX-FileCopyrightText: 2026 Wilson Snyder +// SPDX-License-Identifier: CC0-1.0 + +`verilator_config + +lint_off -rule BADVLTPRAGMA -file "t/t_pp_underline_bad.v" -lines 10