Add regression tests for type identifier task and function names
Check that function and task declarations can use a visible type identifier as the declaration name. Cover both ANSI declarations and the non-ANSI forms where the name is parsed without a separate return type or port list. Also check class method declarations where the method name is the same as the enclosing class name. Add GitHub issue #670 coverage for the `function void` case using the issue-based regression naming scheme. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
24743af7d5
commit
21b0107bae
|
|
@ -0,0 +1,37 @@
|
|||
// Regression test for GitHub issue #670.
|
||||
// Check that a class function can have the same name as the class.
|
||||
|
||||
module test;
|
||||
|
||||
reg failed;
|
||||
|
||||
`define check(value, expected, error) \
|
||||
if ((value) !== (expected)) begin \
|
||||
$display("FAILED(%0d). %s", `__LINE__, error); \
|
||||
$display(" expected %0h, got %0h", expected, value); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
class test;
|
||||
int value;
|
||||
|
||||
function void test();
|
||||
value = 32'd42;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
test tst;
|
||||
|
||||
failed = 1'b0;
|
||||
tst = new;
|
||||
tst.test();
|
||||
|
||||
`check(tst.value, 32'd42, "Class function name did not hide class name");
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Check that function names can shadow visible type identifiers.
|
||||
|
||||
typedef int T;
|
||||
typedef int U;
|
||||
|
||||
module test;
|
||||
|
||||
reg failed;
|
||||
|
||||
`define check(value, expected, error) \
|
||||
if ((value) !== (expected)) begin \
|
||||
$display("FAILED(%0d). %s", `__LINE__, error); \
|
||||
$display(" expected %0h, got %0h", expected, value); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
function int T(input int value);
|
||||
return value + 32'd1;
|
||||
endfunction
|
||||
|
||||
function U;
|
||||
U = 1'b1;
|
||||
endfunction
|
||||
|
||||
class C;
|
||||
function int T(input int value);
|
||||
return value + 32'd2;
|
||||
endfunction
|
||||
|
||||
function int C(input int value);
|
||||
return value + 32'd3;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
C c;
|
||||
|
||||
failed = 1'b0;
|
||||
c = new;
|
||||
|
||||
`check(T(32'd41), 32'd42, "Function name did not hide typedef");
|
||||
`check(U(), 1'b1, "Implicit function name did not hide typedef");
|
||||
`check(c.T(32'd40), 32'd42, "Class function name did not hide typedef");
|
||||
`check(c.C(32'd39), 32'd42, "Class function name did not hide class name");
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
// Check that task names can shadow visible type identifiers.
|
||||
|
||||
typedef int T;
|
||||
typedef int U;
|
||||
|
||||
module test;
|
||||
|
||||
reg failed;
|
||||
|
||||
`define check(value, expected, error) \
|
||||
if ((value) !== (expected)) begin \
|
||||
$display("FAILED(%0d). %s", `__LINE__, error); \
|
||||
$display(" expected %0h, got %0h", expected, value); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
task T(input int value, output int result);
|
||||
result = value + 32'd1;
|
||||
endtask
|
||||
|
||||
task U;
|
||||
output int result;
|
||||
|
||||
result = 32'd33;
|
||||
endtask
|
||||
|
||||
class C;
|
||||
task T(input int value, output int result);
|
||||
result = value + 32'd2;
|
||||
endtask
|
||||
|
||||
task C(input int value, output int result);
|
||||
result = value + 32'd3;
|
||||
endtask
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
C c;
|
||||
int r0;
|
||||
int r1;
|
||||
int r2;
|
||||
int r3;
|
||||
|
||||
failed = 1'b0;
|
||||
c = new;
|
||||
|
||||
T(32'd41, r0);
|
||||
U(r1);
|
||||
c.T(32'd40, r2);
|
||||
c.C(32'd39, r3);
|
||||
|
||||
`check(r0, 32'd42, "Task name did not hide typedef");
|
||||
`check(r1, 32'd33, "Non-ANSI task name did not hide typedef");
|
||||
`check(r2, 32'd42, "Class task name did not hide typedef");
|
||||
`check(r3, 32'd42, "Class task name did not hide class name");
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -37,6 +37,7 @@ br_gh440 vvp_tests/br_gh440.json
|
|||
br_gh483a vvp_tests/br_gh483a.json
|
||||
br_gh483b vvp_tests/br_gh483b.json
|
||||
br_gh552 vvp_tests/br_gh552.json
|
||||
br_gh670 vvp_tests/br_gh670.json
|
||||
br_gh687 vvp_tests/br_gh687.json
|
||||
br_gh703 vvp_tests/br_gh703.json
|
||||
br_gh710a vvp_tests/br_gh710a.json
|
||||
|
|
@ -387,6 +388,7 @@ sv_super_member_fail vvp_tests/sv_super_member_fail.json
|
|||
sv_type_identifier_ams_name_fields vvp_tests/sv_type_identifier_ams_name_fields.json
|
||||
sv_type_identifier_config_name vvp_tests/sv_type_identifier_config_name.json
|
||||
sv_type_identifier_foreach_name vvp_tests/sv_type_identifier_foreach_name.json
|
||||
sv_type_identifier_function_name vvp_tests/sv_type_identifier_function_name.json
|
||||
sv_type_identifier_genvar_name vvp_tests/sv_type_identifier_genvar_name.json
|
||||
sv_type_identifier_modport_name vvp_tests/sv_type_identifier_modport_name.json
|
||||
sv_type_identifier_module_name vvp_tests/sv_type_identifier_module_name.json
|
||||
|
|
@ -399,6 +401,7 @@ sv_type_identifier_parameter_type_param_name vvp_tests/sv_type_identifier_parame
|
|||
sv_type_identifier_port_name vvp_tests/sv_type_identifier_port_name.json
|
||||
sv_type_identifier_specparam_name vvp_tests/sv_type_identifier_specparam_name.json
|
||||
sv_type_identifier_task_function_argument_name vvp_tests/sv_type_identifier_task_function_argument_name.json
|
||||
sv_type_identifier_task_name vvp_tests/sv_type_identifier_task_name.json
|
||||
sv_type_identifier_variable_name vvp_tests/sv_type_identifier_variable_name.json
|
||||
sv_type_param_restrict_class1 vvp_tests/sv_type_param_restrict_class1.json
|
||||
sv_type_param_restrict_class2 vvp_tests/sv_type_param_restrict_class2.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "br_gh670.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_identifier_function_name.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_type_identifier_task_name.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Classes are not supported",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue