Skip to content

Commit

Permalink
Merge pull request #292 from diffblue/verilog-this
Browse files Browse the repository at this point in the history
Verilog: this
  • Loading branch information
kroening authored Oct 14, 2024
2 parents 87f7f4a + b24fd75 commit 8446ca7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions regression/verilog/expressions/this1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
this1.sv

^file .* line 3: 'this' outside of method$
^EXIT=2$
^SIGNAL=0$
--
5 changes: 5 additions & 0 deletions regression/verilog/expressions/this1.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module main;

wire y = this;

endmodule
1 change: 1 addition & 0 deletions src/verilog/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -3661,6 +3661,7 @@ primary: primary_literal
| cast
| assignment_pattern_expression
| TOK_NULL { init($$, ID_NULL); }
| TOK_THIS { init($$, ID_this); }
;

primary_literal:
Expand Down
5 changes: 5 additions & 0 deletions src/verilog/verilog_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@ exprt verilog_typecheck_exprt::convert_nullary_expr(nullary_exprt expr)
expr.type() = elaborate_type(expr.type());
return std::move(expr);
}
else if(expr.id() == ID_this)
{
throw errort().with_location(expr.source_location())
<< "'this' outside of method";
}
else
{
throw errort().with_location(expr.source_location())
Expand Down

0 comments on commit 8446ca7

Please sign in to comment.