Fix enum ranges without colons, bug1204.

This commit is contained in:
Wilson Snyder 2017-09-12 18:53:57 -04:00
parent 691fbb0c42
commit 3dacd87dfb
3 changed files with 6 additions and 2 deletions

View File

@ -4,6 +4,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
* Verilator 3.911 devel
**** Fix enum ranges without colons, bug1204. [Mike Popoloski]
* Verilator 3.910 2017-09-07

View File

@ -1547,7 +1547,7 @@ enum_name_declaration<nodep>: // ==IEEE: enum_name_declaration
enumNameRangeE<nodep>: // IEEE: second part of enum_name_declaration
/* empty */ { $$ = NULL; }
| '[' intnumAsConst ']' { $$ = new AstRange($1,new AstConst($1,0), $2); }
| '[' intnumAsConst ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstConst($1, $2->toSInt()-1)); }
| '[' intnumAsConst ':' intnumAsConst ']' { $$ = new AstRange($1,$2,$4); }
;
@ -1556,7 +1556,7 @@ enumNameStartE<nodep>: // IEEE: third part of enum_name_declaration
| '=' constExpr { $$ = $2; }
;
intnumAsConst<nodep>:
intnumAsConst<constp>:
yaINTNUM { $$ = new AstConst($<fl>1,*$1); }
;

View File

@ -19,6 +19,7 @@ module t (/*AUTOARG*/);
e3=3,
e5=FIVE,
e10_[2] = 10,
e12,
e20_[5:7] = 25,
e20_z,
e30_[7:5] = 30,
@ -44,6 +45,7 @@ module t (/*AUTOARG*/);
if (e5 !== 5) $stop;
if (e10_0 !== 10) $stop;
if (e10_1 !== 11) $stop;
if (e12 !== 12) $stop;
if (e20_5 !== 25) $stop;
if (e20_6 !== 26) $stop;
if (e20_7 !== 27) $stop;