Internals: Move CASEX warning with other case lints; add test

This commit is contained in:
Wilson Snyder 2010-01-09 11:09:14 -05:00
parent 6aec0ce702
commit 0d12fe43a0
4 changed files with 10 additions and 4 deletions

View File

@ -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()) {

View File

@ -1911,7 +1911,7 @@ unique_priorityE<uniqstate>: // IEEE: unique_priority + empty
caseStart<casep>: // 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); }
;

View File

@ -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);

View File

@ -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;