With -Wpendantic allow circular assigns

This commit is contained in:
Wilson Snyder 2026-04-23 00:50:12 -04:00
parent 5064a5ee65
commit c1d1b333ac
6 changed files with 54 additions and 3 deletions

View File

@ -2229,7 +2229,9 @@ class ConstVisitor final : public VNVisitor {
&& !VN_IS(nodep, AssignDly)) {
// X = X. Quite pointless, though X <= X may override another earlier assignment
if (VN_IS(nodep, AssignW)) {
nodep->v3error("Wire inputs its own output, creating circular logic (wire x=x)");
if (!v3Global.opt.pedantic())
nodep->v3error(
"Wire inputs its own output, creating circular logic (wire x=x)");
return false; // Don't delete the assign, or V3Gate will freak out
} else {
VL_DO_DANGLING(pushDeletep(nodep->unlinkFrBack()), nodep);

View File

@ -134,7 +134,6 @@ for s in [
'Unsupported: Size-changing cast on non-basic data type',
'Unsupported: Slice of non-constant bounds',
'Unsupported: Stream operation on a variable of a type',
'Unsupported: Unclocked assertion',
'Unsupported: Using --protect-ids with public function',
'Unsupported: Verilog 1995 gate primitive:',
'Unsupported: [] dimensions',
@ -153,7 +152,6 @@ for s in [
'Unsupported: super',
'Unsupported: with[] stream expression',
'expected non-complex non-double',
'is not an unpacked array, but is in an unpacked array context',
'loading other than unpacked-array variable',
'loading other than unpacked/associative-array variable',
]:

View File

@ -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: 2024 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator_st')
test.compile(verilator_flags2=['--binary --Wpedantic'])
test.execute()
test.passes()

View File

@ -0,0 +1,11 @@
// 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
module t;
wire w;
assign w = w;
initial $finish;
endmodule

View File

@ -0,0 +1,5 @@
%Error: t/t_lint_wireloop.v:9:12: Wire inputs its own output, creating circular logic (wire x=x)
9 | assign w = w;
| ^
... See the manual at https://verilator.org/verilator_doc.html?v=latest for more assistance.
%Error: Exiting due to

View File

@ -0,0 +1,17 @@
#!/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: 2024 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('linter')
test.top_filename = "t/t_lint_wireloop.v"
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()