Merge pull request #773 from larsclausen/function-return-class
Support class objects as function return values
This commit is contained in:
commit
463f18a03f
10
elab_expr.cc
10
elab_expr.cc
|
|
@ -2783,10 +2783,14 @@ NetExpr* PECallFunction::elaborate_expr_(Design*des, NetScope*scope,
|
|||
NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
|
||||
ivl_type_t type, unsigned flags) const
|
||||
{
|
||||
//cerr << "HERE: " << scope->basename() << ", " << *type << endl;
|
||||
const netdarray_t*darray = dynamic_cast<const netdarray_t*>(type);
|
||||
assert(darray);
|
||||
return elaborate_expr(des, scope, darray->element_type()->packed_width(), flags);
|
||||
unsigned int width = 1;
|
||||
// Icarus allows a dynamic array to be initialised with a single
|
||||
// elementary value, in that case the expression needs to be evaluated
|
||||
// with the rigth width.
|
||||
if (darray)
|
||||
width = darray->element_type()->packed_width();
|
||||
return elaborate_expr(des, scope, width, flags);
|
||||
}
|
||||
|
||||
NetExpr* PECallFunction::elaborate_base_(Design*des, NetScope*scope, NetScope*dscope,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
// Check that functions returning a class object are supported
|
||||
|
||||
module test;
|
||||
|
||||
class C;
|
||||
int i;
|
||||
task t;
|
||||
if (i == 10) begin
|
||||
$display("PASSED");
|
||||
end else begin
|
||||
$display("FAILED");
|
||||
end
|
||||
endtask
|
||||
endclass
|
||||
|
||||
function C f;
|
||||
C c;
|
||||
c = new;
|
||||
c.i = 10;
|
||||
return c;
|
||||
endfunction
|
||||
|
||||
initial begin
|
||||
C c;
|
||||
c = f();
|
||||
c.t;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -533,6 +533,7 @@ sv_class_property_signed1 normal,-g2009 ivltests
|
|||
sv_class_property_signed2 normal,-g2009 ivltests
|
||||
sv_class_property_signed3 normal,-g2009 ivltests
|
||||
sv_class_property_signed4 normal,-g2009 ivltests
|
||||
sv_class_return normal,-g2009 ivltests
|
||||
sv_class_static_prop1 normal,-g2009 ivltests
|
||||
sv_class_static_prop2 normal,-g2009 ivltests
|
||||
sv_class_static_prop3 normal,-g2009 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue