diff --git a/Changes b/Changes index e95de00ea..27ba7325b 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/src/verilog.y b/src/verilog.y index 47e50b56e..2a97499b7 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1547,7 +1547,7 @@ enum_name_declaration: // ==IEEE: enum_name_declaration enumNameRangeE: // 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: // IEEE: third part of enum_name_declaration | '=' constExpr { $$ = $2; } ; -intnumAsConst: +intnumAsConst: yaINTNUM { $$ = new AstConst($1,*$1); } ; diff --git a/test_regress/t/t_enum.v b/test_regress/t/t_enum.v index 1681cb603..272471649 100644 --- a/test_regress/t/t_enum.v +++ b/test_regress/t/t_enum.v @@ -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;