forked from github/verilator
Fix error on unsupported recursive functions (#2957).
This commit is contained in:
parent
31121141db
commit
13ddd0bc1c
2
Changes
2
Changes
@ -19,7 +19,7 @@ Verilator 4.205 devel
|
||||
**Minor:**
|
||||
|
||||
* Merge const static data globally into a new constant pool (#3013). [Geza Lore]
|
||||
|
||||
* Fix error on unsupported recursive functions (#2957). [Trefor Southwell]
|
||||
|
||||
|
||||
Verilator 4.204 2021-06-12
|
||||
|
@ -2666,11 +2666,17 @@ private:
|
||||
UINFO(7, " ErrFtask curSymp=se" << cvtToHex(m_curSymp) << " dotSymp=se"
|
||||
<< cvtToHex(dotSymp) << endl);
|
||||
if (foundp) {
|
||||
nodep->v3error("Found definition of '"
|
||||
<< m_ds.m_dotText << (m_ds.m_dotText == "" ? "" : ".")
|
||||
<< nodep->prettyName() << "'"
|
||||
<< " as a " << foundp->nodep()->typeName()
|
||||
<< " but expected a task/function");
|
||||
if (VN_IS(foundp->nodep(), Var) && m_ds.m_dotText == "" && m_ftaskp
|
||||
&& m_ftaskp->name() == foundp->nodep()->name()) {
|
||||
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Recursive function call "
|
||||
<< nodep->prettyNameQ());
|
||||
} else {
|
||||
nodep->v3error("Found definition of '"
|
||||
<< m_ds.m_dotText << (m_ds.m_dotText == "" ? "" : ".")
|
||||
<< nodep->prettyName() << "'"
|
||||
<< " as a " << foundp->nodep()->typeName()
|
||||
<< " but expected a task/function");
|
||||
}
|
||||
} else if (VN_IS(nodep, New) && m_statep->forPrearray()) {
|
||||
// Resolved in V3Width
|
||||
} else if (nodep->dotted() == "") {
|
||||
|
5
test_regress/t/t_func_bad3.out
Normal file
5
test_regress/t/t_func_bad3.out
Normal file
@ -0,0 +1,5 @@
|
||||
%Error-UNSUPPORTED: t/t_func_bad3.v:12:27: Unsupported: Recursive function call 'recurse_self'
|
||||
12 | else recurse_self = recurse_self(i - 1) + 1;
|
||||
| ^~~~~~~~~~~~
|
||||
... For error description see https://verilator.org/warn/UNSUPPORTED?v=latest
|
||||
%Error: Exiting due to
|
19
test_regress/t/t_func_bad3.pl
Executable file
19
test_regress/t/t_func_bad3.pl
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
scenarios(simulator => 1);
|
||||
|
||||
compile(
|
||||
fails => $Self->{vlt_all},
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
15
test_regress/t/t_func_bad3.v
Normal file
15
test_regress/t/t_func_bad3.v
Normal file
@ -0,0 +1,15 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
|
||||
function recurse_self;
|
||||
input i;
|
||||
if (i == 0) recurse_self = 0;
|
||||
else recurse_self = recurse_self(i - 1) + 1;
|
||||
endfunction
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user