From 0d12fe43a0923e7ffff9e5449ce592381c5d6917 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 9 Jan 2010 11:09:14 -0500 Subject: [PATCH] Internals: Move CASEX warning with other case lints; add test --- src/V3Case.cpp | 3 +++ src/verilog.y | 2 +- test_regress/t/t_case_x_bad.pl | 6 +++--- test_regress/t/t_case_x_bad.v | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/V3Case.cpp b/src/V3Case.cpp index 592ac5c3f..ba2f4caf0 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -67,6 +67,9 @@ private: } virtual void visit(AstNodeCase* nodep, AstNUser*) { + if (nodep->castCase() && nodep->castCase()->casex()) { + nodep->v3warn(CASEX,"Suggest casez (with ?'s) in place of casex (with X's)\n"); + } // Detect multiple defaults bool hitDefault = false; for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) { diff --git a/src/verilog.y b/src/verilog.y index 8bdd19f61..76826038b 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1911,7 +1911,7 @@ unique_priorityE: // IEEE: unique_priority + empty caseStart: // IEEE: part of case_statement yCASE '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASE,$3,NULL); } - | yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASEX,$3,NULL); $1->v3warn(CASEX,"Suggest casez (with ?'s) in place of casex (with X's)\n"); } + | yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASEX,$3,NULL); } | yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASEZ,$3,NULL); } ; diff --git a/test_regress/t/t_case_x_bad.pl b/test_regress/t/t_case_x_bad.pl index 66f82266a..2bdad4fba 100755 --- a/test_regress/t/t_case_x_bad.pl +++ b/test_regress/t/t_case_x_bad.pl @@ -11,9 +11,9 @@ compile ( v_flags2 => ["--lint-only"], fails=>1, expect=> -'%Warning-CASEWITHX: t/t_case_x_bad.v:\d+: Use of x/\? constant in case statement, \(perhaps intended casex/casez\) -.* -%Error: Exiting due to.*', +'%Warning-CASEX: t/t_case_x_bad.v:\d+: Suggest casez \(with \?\'s\) in place of casex \(with X\'s\) +.*%Warning-CASEWITHX: t/t_case_x_bad.v:\d+: Use of x/\? constant in case statement, \(perhaps intended casex/casez\) +.*%Error: Exiting due to.*', ); ok(1); diff --git a/test_regress/t/t_case_x_bad.v b/test_regress/t/t_case_x_bad.v index 4e7a5866b..126a88d37 100644 --- a/test_regress/t/t_case_x_bad.v +++ b/test_regress/t/t_case_x_bad.v @@ -10,6 +10,9 @@ module t (/*AUTOARG*/ input [3:0] value; always @ (/*AS*/value) begin + casex (value) + default: $stop; + endcase case (value) 4'b0000: $stop; 4'b1xxx: $stop;