From f0c569ab0da8b13b220455c60407dadcc47e3d41 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 23 May 2026 19:56:28 -0400 Subject: [PATCH] Fix CASEINCOMPLETE to not warn on `unique0 case` (#7647). Fixes #7647. --- Changes | 1 + docs/guide/warnings.rst | 3 +++ src/V3Case.cpp | 13 ++++++++----- test_regress/t/t_lint_caseincomplete_bad.v | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index 8007838b5..cd6e5d4c8 100644 --- a/Changes +++ b/Changes @@ -83,6 +83,7 @@ Verilator 5.049 devel * Fix force determinism (#7620) (#7637). [Artur Bieniek, Antmicro Ltd.] * Fix reference counting for modport task references (#7628). [Nick Brereton] * Fix implicit conversions of VlWide (#7642). [Geza Lore, Testorrent USA, Inc.] +* Fix CASEINCOMPLETE to not warn on `unique0 case` (#7647). Verilator 5.048 2026-04-26 diff --git a/docs/guide/warnings.rst b/docs/guide/warnings.rst index 4ce0a8cee..0ed315330 100644 --- a/docs/guide/warnings.rst +++ b/docs/guide/warnings.rst @@ -382,6 +382,9 @@ List Of Warnings non-enumerated values (IEEE 1800-2023 12.5.3). Verilator checks that illegal values are not hit, unless :vlopt:`--no-assert-case` was used. + Unique0 case statements will never cause this warning. (Although unique0 + should be avoided in synthesizable code as may result in latch behavior.) + Ignoring this warning will only suppress the lint check; it will simulate correctly. diff --git a/src/V3Case.cpp b/src/V3Case.cpp index e2baca0a5..4eca73e01 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -178,8 +178,10 @@ class CaseVisitor final : public VNVisitor { for (uint32_t i = 0; i < numCases; ++i) { if ((i & mask) == val) { if (!m_valueItem[i]) { - nodep->v3warn(CASEINCOMPLETE, "Enum item " << itemp->prettyNameQ() - << " not covered by case\n"); + if (!nodep->unique0Pragma()) + nodep->v3warn(CASEINCOMPLETE, "Enum item " + << itemp->prettyNameQ() + << " not covered by case\n"); m_caseIncomplete = true; return false; // enum has uncovered value by case items } @@ -310,9 +312,10 @@ class CaseVisitor final : public VNVisitor { } else { for (uint32_t i = 0; i < numCases; ++i) { if (!m_valueItem[i]) { // has uncovered case - nodep->v3warn(CASEINCOMPLETE, "Case values incompletely covered " - "(example pattern 0x" - << std::hex << i << ")"); + if (!nodep->unique0Pragma()) + nodep->v3warn(CASEINCOMPLETE, "Case values incompletely covered " + "(example pattern 0x" + << std::hex << i << ")"); m_caseIncomplete = true; m_caseNoOverlapsAllCovered = false; return false; diff --git a/test_regress/t/t_lint_caseincomplete_bad.v b/test_regress/t/t_lint_caseincomplete_bad.v index 81678a474..2a8bf8edf 100644 --- a/test_regress/t/t_lint_caseincomplete_bad.v +++ b/test_regress/t/t_lint_caseincomplete_bad.v @@ -14,5 +14,10 @@ module t ( 2'b10: ; 2'b11: ; endcase + + unique0 case (i) // No warning + 2'b00: ; + endcase end + endmodule