Add additional regression tests for class syntax

Check that it is possible to both declare and call class constructors
without using parenthesis after the `new` keyword.

Check that a non-ANSI port for a class constructor results in an error.

Check that it is possible to invoke a class task through a implicit class
handle (`this` or `super`) without using parenthesis after the task name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-03-26 20:37:41 +01:00
parent 51eae02e78
commit 571f222a73
7 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,14 @@
// Check that a class constructor declaration without parenthesis after the
// `new` is supported.
module test;
class C;
function new;
$display("PASSED");
endfunction
endclass
C c = new;
endmodule

View File

@ -0,0 +1,14 @@
// Check that a class constructor with non-ANSI port results in an error.
module test;
class C;
function new;
input x; // This is a syntax error
$display("FAILED");
endfunction
endclass
C c = new;
endmodule

View File

@ -0,0 +1,21 @@
// Check that it is possible to explicitly call the base class constructor, even
// if it does not take any parameters. Check that it is possible to call it with
// parenthesis after the `new`.
module test;
class B;
function new();
$display("PASSED");
endfunction
endclass
class C extends B;
function new();
super.new();
endfunction
endclass
C c = new;
endmodule

View File

@ -0,0 +1,21 @@
// Check that it is possible to explicitly call the base class constructor, even
// if it does not take any parameters. Check that it is possible to call it
// without parenthesis after the `new`.
module test;
class B;
function new();
$display("PASSED");
endfunction
endclass
class C extends B;
function new();
super.new;
endfunction
endclass
C c = new;
endmodule

View File

@ -0,0 +1,22 @@
// Check that it is possible to call a class task without parenthesis after the
// task name when using the implicit `this` class handle.
module test;
class C;
task a;
$display("PASSED");
endtask
task b;
this.a;
endtask
endclass
C c = new;
initial begin
c.b;
end
endmodule

View File

@ -474,11 +474,16 @@ sv_class21 normal,-g2009 ivltests
sv_class22 normal,-g2009 ivltests
sv_class23 normal,-g2009 ivltests
sv_class24 normal,-g2009 ivltests
sv_class_constructor1 normal,-g2009 ivltests
sv_class_constructor_fail CE,-g2009 ivltests
sv_class_empty_item normal,-g2009 ivltests
sv_class_extends_scoped normal,-g2009 ivltests
sv_class_localparam normal,-g2009 ivltests
sv_class_new_init normal,-g2009 ivltests
sv_class_in_module_decl normal,-g2009 ivltests
sv_class_super1 normal,-g2009 ivltests
sv_class_super2 normal,-g2009 ivltests
sv_class_task1 normal,-g2009 ivltests
sv_darray1 normal,-g2009 ivltests
sv_darray2 normal,-g2009 ivltests
sv_darray3 normal,-g2009 ivltests

View File

@ -372,11 +372,15 @@ sv_class21 CE,-g2009 ivltests
sv_class22 CE,-g2009 ivltests
sv_class23 CE,-g2009 ivltests
sv_class24 CE,-g2009 ivltests
sv_class_constructor1 CE,-g2009 ivltests
sv_class_empty_item CE,-g2009 ivltests
sv_class_extends_scoped CE,-g2009 ivltests
sv_class_localparam CE,-g2009 ivltests
sv_class_new_init CE,-g2009 ivltests
sv_class_in_module_decl CE,-g2009 ivltests
sv_class_super1 CE,-g2009 ivltests
sv_class_super2 CE,-g2009 ivltests
sv_class_task1 CE,-g2009 ivltests
sv_end_label CE,-g2009 ivltests # Also generate
sv_foreach2 CE,-g2009,-pallowsigned=1 ivltests
sv_foreach3 CE,-g2009 ivltests