Skip to content

Commit 9f83d50

Browse files
authored
Merge pull request #1391 from diffblue/sv-lhs-assignment-pattern
SystemVerilog: grammar for assignment patterns on LHS
2 parents e009e1b + cacd935 commit 9f83d50

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
KNOWNBUG
1+
CORE
22
assignment-pattern-lhs1.sv
33

4-
^EXIT=0$
4+
^file .* line 9: no support for assignment patterns on LHS of an assignment$
5+
^EXIT=2$
56
^SIGNAL=0$
67
--
78
--
8-
This does not parse.

regression/verilog/assignments/assignment-pattern-lhs1.sv

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
module main;
22

3-
typedef struct packed {int a, b;} S;
4-
S my_s;
53
int x, y;
64

75
initial begin
86
// Assignment pattern on LHS.
97
// Does not parse with Icarus Verilog, VCS, XCelium.
108
// Works with Riviera, Questa.
11-
'{x, y} = S'{1, 2};
9+
'{x, y} = '{1, 2};
1210

1311
assert(x == 1 && y == 2);
1412
end

src/verilog/parser.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4558,6 +4558,7 @@ variable_lvalue:
45584558
| '{' variable_concatenation_lvalue_brace '}'
45594559
{ init($$, ID_concatenation); swapop($$, $2); }
45604560
*/
4561+
| assignment_pattern
45614562
;
45624563

45634564
variable_concatenation_lvalue_brace:

src/verilog/verilog_typecheck.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,11 @@ void verilog_typecheckt::check_lhs(
760760
{
761761
check_lhs(to_member_expr(lhs).struct_op(), vassign);
762762
}
763+
else if(lhs.id() == ID_verilog_assignment_pattern)
764+
{
765+
throw errort().with_location(lhs.source_location())
766+
<< "no support for assignment patterns on LHS of an assignment";
767+
}
763768
else
764769
{
765770
throw errort() << "typechecking: failed to get identifier on LHS "
@@ -1019,8 +1024,8 @@ void verilog_typecheckt::convert_assign(
10191024

10201025
convert_expr(lhs);
10211026
convert_expr(rhs);
1022-
assignment_conversion(rhs, lhs.type());
10231027
check_lhs(lhs, blocking?A_BLOCKING:A_NON_BLOCKING);
1028+
assignment_conversion(rhs, lhs.type());
10241029
}
10251030

10261031
/*******************************************************************\

0 commit comments

Comments
 (0)