File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
regression/verilog/structs Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ CORE
2+ unpacked_struct2.sv
3+
4+ ^file .* line 9: failed to convert `signed \[31:0\]' to `struct'$
5+ ^EXIT=2$
6+ ^SIGNAL=0$
7+ --
Original file line number Diff line number Diff line change 1+ module main ;
2+
3+ // an unpacked struct type
4+ typedef struct {
5+ bit field;
6+ } s_type ;
7+
8+ // bit-vectors cannot be assigned to unpacked structs
9+ wire s_type w = 123 ;
10+
11+ endmodule
Original file line number Diff line number Diff line change @@ -223,6 +223,14 @@ void verilog_typecheck_exprt::assignment_conversion(
223223 if (lhs_type == rhs.type ())
224224 return ;
225225
226+ if (lhs_type.id () == ID_struct && !lhs_type.get_bool (ID_packed))
227+ {
228+ // assignment of a non-matching type to unpacked struct
229+ throw errort ().with_location (rhs.source_location ())
230+ << " failed to convert `" << to_string (original_rhs_type) << " ' to `"
231+ << to_string (lhs_type) << " '" ;
232+ }
233+
226234 // do enum, union and struct decay
227235 enum_decay (rhs);
228236 struct_decay (rhs);
You can’t perform that action at this time.
0 commit comments