Skip to content

Commit ab3f74c

Browse files
committed
SystemVerilog: allow assignment of new to any class type
The new expression has no self-determined type; this allows assignment to any class type.
1 parent 2be0696 commit ab3f74c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

regression/verilog/class/new1.desc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
KNOWNBUG
1+
CORE
22
new1.sv
33

4-
^EXIT=0$
4+
^EXIT=10$
55
^SIGNAL=0$
66
--
77
--
8-
The class is not yet recognized as a type.

src/verilog/verilog_typecheck_expr.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ void verilog_typecheck_exprt::assignment_conversion(
269269
}
270270
}
271271

272+
if(rhs.type().id() == ID_verilog_new)
273+
{
274+
if(lhs_type.id() == ID_verilog_class_type)
275+
{
276+
rhs = typecast_exprt{rhs, lhs_type};
277+
return;
278+
}
279+
}
280+
272281
// "The size of the left-hand side of an assignment forms
273282
// the context for the right-hand expression."
274283

0 commit comments

Comments
 (0)