Skip to content

Commit a42dd63

Browse files
committed
Verilog: fix assignment context semantics
1 parent 4240ae8 commit a42dd63

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
assignment-context1.sv
33

44
^EXIT=0$
55
^SIGNAL=0$
66
--
77
^warning: ignoring
88
--
9-
The variants that enlarge give a wrong answer.

src/verilog/verilog_typecheck.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,12 @@ void verilog_typecheckt::assignment_conversion(
4242
const typet &lhs_type)
4343
{
4444
// Implements 1800-2017 10.7
45-
// If the RHS is smaller than the LHS:
46-
// * if the RHS is unsigned, it is zero-padded
47-
// * if the RHS is signed, it is sign-extended
48-
// If the RHS is larger than the LHS, it is truncated.
49-
50-
// This matches our typecast, but differs from the steps taken
51-
// when evaluating binary expressions (11.8.2), where sign
52-
// extension only happens when the propagated type is signed.
53-
implicit_typecast(rhs, lhs_type);
45+
// "The size of the left-hand side of an assignment forms
46+
// the context for the right-hand expression."
47+
48+
// This is _size_ only, the type of the RHS is retained.
49+
50+
downwards_type_propagation(rhs, lhs_type);
5451
}
5552

5653
/*******************************************************************\

0 commit comments

Comments
 (0)