Merge pull request #780 from larsclausen/nb-auto-struct-fail
Prevent non-blocking writes to fields of automatic structs
This commit is contained in:
commit
b0c262de80
22
PExpr.cc
22
PExpr.cc
|
|
@ -446,19 +446,17 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
|
||||||
|
|
||||||
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
|
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
|
||||||
{
|
{
|
||||||
NetNet* net = 0;
|
symbol_search_results sr;
|
||||||
ivl_type_t cls_val;
|
if (!symbol_search(this, des, scope, path_, &sr))
|
||||||
const NetExpr*par = 0;
|
|
||||||
ivl_type_t par_type;
|
|
||||||
NetEvent* eve = 0;
|
|
||||||
|
|
||||||
scope = symbol_search(this, des, scope, path_, net, par, eve,
|
|
||||||
par_type, cls_val);
|
|
||||||
|
|
||||||
if (scope)
|
|
||||||
return scope->is_auto();
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
return sr.scope->is_auto();
|
||||||
}
|
}
|
||||||
|
|
||||||
PENewArray::PENewArray(PExpr*size_expr, PExpr*init_expr)
|
PENewArray::PENewArray(PExpr*size_expr, PExpr*init_expr)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -104,6 +104,8 @@ assign_op_oob normal,-g2009 ivltests
|
||||||
assign_op_real_array normal,-g2009 ivltests
|
assign_op_real_array normal,-g2009 ivltests
|
||||||
assign_op_real_array_oob normal,-g2009 ivltests
|
assign_op_real_array_oob normal,-g2009 ivltests
|
||||||
assign_op_type 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
|
bitp1 normal,-g2005-sv ivltests
|
||||||
bits normal,-g2005-sv ivltests
|
bits normal,-g2005-sv ivltests
|
||||||
bits2 normal,-g2005-sv ivltests
|
bits2 normal,-g2005-sv ivltests
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue