File tree 2 files changed +22
-7
lines changed
regression/verilog/data-types
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 1
- KNOWNBUG
1
+ CORE
2
2
enum_initializers1.sv
3
-
4
- ^EXIT=10$
3
+ --bound 0
4
+ ^\[main\.property\.pA\] always 1 == 1: PROVED up to bound 0$
5
+ ^\[main\.property\.pB\] always 1 \+ 10 == 11: PROVED up to bound 0$
6
+ ^EXIT=0$
5
7
^SIGNAL=0$
6
8
--
7
9
--
8
- Crashes with missing identifier
9
-
Original file line number Diff line number Diff line change @@ -1665,8 +1665,23 @@ void verilog_typecheck_exprt::tc_binary_expr(
1665
1665
const exprt &expr,
1666
1666
exprt &op0, exprt &op1)
1667
1667
{
1668
- const typet new_type=max_type (op0.type (), op1.type ());
1669
-
1668
+ // Verilog enum types decay to their base type when used in relational
1669
+ // or arithmetic expressions.
1670
+ auto enum_decay = [](const typet &type) {
1671
+ if (type.get (ID_C_verilog_type) == ID_verilog_enum)
1672
+ {
1673
+ typet result = type;
1674
+ result.remove (ID_C_verilog_type);
1675
+ result.remove (ID_C_identifier);
1676
+ return result;
1677
+ }
1678
+ else
1679
+ return type;
1680
+ };
1681
+
1682
+ const typet new_type =
1683
+ max_type (enum_decay (op0.type ()), enum_decay (op1.type ()));
1684
+
1670
1685
if (new_type.is_nil ())
1671
1686
{
1672
1687
throw errort ().with_location (expr.source_location ())
You can’t perform that action at this time.
0 commit comments