verilator/test_regress/t/t_class_func_nvoid_bad.v

77 lines
1.5 KiB
Systemverilog
Raw Normal View History

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2020 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
class Cls;
2026-03-08 23:26:40 +01:00
function int fi();
return 10;
endfunction
function void fv();
endfunction
task t();
endtask
static function int sfi();
return 10;
endfunction
static function void sfv();
endfunction
static task st();
endtask
endclass
module t;
2026-03-08 23:26:40 +01:00
function int mod_fi();
return 10;
endfunction
function void mod_fv();
endfunction
task mod_t();
endtask
2026-03-08 23:26:40 +01:00
initial begin
Cls c;
c = new;
2026-03-08 23:26:40 +01:00
// For test of calling function in void context, see t_func_void_bad.v
2026-03-08 23:26:40 +01:00
// Module
if (mod_fi() != 10) $stop; // OK
void'(mod_fi()); // OK
2026-03-08 23:26:40 +01:00
mod_fv(); // Warn IGNOREDRETURN
void'(mod_fv()); // OK
if (mod_fv() == 10) $stop; // Bad call of task as function
2026-03-08 23:26:40 +01:00
mod_t(); // OK
if (mod_t() == 10) $stop; // Bad call of task as function
2026-03-08 23:26:40 +01:00
// Member functions
if (c.fi() != 10) $stop; // OK
void'(c.fi()); // OK
2026-03-08 23:26:40 +01:00
c.fv(); // Ok
void'(c.fv()); // OK
if (c.fv() == 10) $stop; // Bad
2026-03-08 23:26:40 +01:00
c.t(); // OK
if (c.t() == 10) $stop; // Bad
2026-03-08 23:26:40 +01:00
// Static member functions
if (c.sfi() != 10) $stop; // OK
void'(c.sfi()); // OK
2026-03-08 23:26:40 +01:00
c.sfv(); // Ok
void'(c.sfv()); // OK
if (c.sfv() == 10) $stop; // Bad
2026-03-08 23:26:40 +01:00
c.st(); // OK
if (c.st() == 10) $stop; // Bad
2026-03-08 23:26:40 +01:00
$stop;
end
endmodule