Merge pull request #780 from larsclausen/nb-auto-struct-fail

Prevent non-blocking writes to fields of automatic structs
This commit is contained in:
Stephen Williams 2022-10-14 08:13:53 -07:00 committed by GitHub
commit b0c262de80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 11 deletions

View File

@ -446,19 +446,17 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
{
NetNet* net = 0;
ivl_type_t cls_val;
const NetExpr*par = 0;
ivl_type_t par_type;
NetEvent* eve = 0;
symbol_search_results sr;
if (!symbol_search(this, des, scope, path_, &sr))
return false;
scope = symbol_search(this, des, scope, path_, net, par, eve,
par_type, cls_val);
// Class properties are not considered automatic since a non-blocking
// assignment to an object stored in an automatic variable is supposed to
// capture a reference to the object, not the variable.
if (!sr.path_tail.empty() && sr.net && sr.net->class_type())
return false;
if (scope)
return scope->is_auto();
else
return false;
return sr.scope->is_auto();
}
PENewArray::PENewArray(PExpr*size_expr, PExpr*init_expr)

View File

@ -0,0 +1,18 @@
// Check that it is not possible to perform non-blocking assignments to fields
// of structs with automatic lifetime.
module test;
task automatic auto_task;
struct packed {
logic x;
} s;
s.x <= 10;
$display("FAILED");
endtask
initial begin
auto_task;
end
endmodule

View File

@ -0,0 +1,19 @@
// Check that it is not possible to perform non-blocking assignments to a class
// object variable with automatic lifetime.
module test;
class C;
endclass
task automatic auto_task;
C c1, c2;
c1 <= c2;
$display("FAILED");
endtask
initial begin
auto_task;
end
endmodule

View File

@ -104,6 +104,8 @@ assign_op_oob normal,-g2009 ivltests
assign_op_real_array normal,-g2009 ivltests
assign_op_real_array_oob normal,-g2009 ivltests
assign_op_type normal,-g2009 ivltests
automatic_error14 CE,-g2005-sv ivltests
automatic_error15 CE,-g2005-sv ivltests
bitp1 normal,-g2005-sv ivltests
bits normal,-g2005-sv ivltests
bits2 normal,-g2005-sv ivltests