From 7c443ab1083cbb22364d10f724453db79de5e4ba Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 21 Nov 2017 21:52:37 -0500 Subject: [PATCH] Fix error on "unique case" with no cases. --- Changes | 2 ++ src/V3Assert.cpp | 6 ++++++ test_regress/t/t_assert_casez.v | 3 +++ 3 files changed, 11 insertions(+) diff --git a/Changes b/Changes index bbf358e1d..62fccc73b 100644 --- a/Changes +++ b/Changes @@ -20,6 +20,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix false unused warning on interfaces, bug1241. [Laurens van Dam] +**** Fix error on "unique case" with no cases. + * Verilator 3.914 2017-10-14 diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index 964910e38..377f6a0ac 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -202,6 +202,9 @@ private: AstNode *newifp = nodep->cloneTree(false); bool allow_none = nodep->unique0Pragma(); + // Empty case means no property + if (!propp) propp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + // Note: if this ends with an 'else', then we don't need to validate that one of the // predicates evaluates to true. AstNode* ohot = ((allow_none || hasDefaultElse) @@ -259,6 +262,9 @@ private: else propp = onep; } } + // Empty case means no property + if (!propp) propp = new AstConst(nodep->fileline(), AstConst::LogicFalse()); + bool allow_none = has_default || nodep->unique0Pragma(); AstNode* ohot = (allow_none ? static_cast(new AstOneHot0(nodep->fileline(), propp)) diff --git a/test_regress/t/t_assert_casez.v b/test_regress/t/t_assert_casez.v index 106a8ebd8..760b628de 100644 --- a/test_regress/t/t_assert_casez.v +++ b/test_regress/t/t_assert_casez.v @@ -20,6 +20,9 @@ module t; 2'b01 : ; 2'b1? : ; endcase + unique casez (1'b1) + default: ; + endcase $write("*-* All Finished *-*\n"); $finish; end