Fix internal error instead of missing prototype error (#7485). [Alex Solomatnikov]

Fixes #7485.
This commit is contained in:
Wilson Snyder 2026-04-28 17:59:18 -04:00
parent 6aebcd2b1c
commit 8f18f0cf22
6 changed files with 54 additions and 1 deletions

View File

@ -17,6 +17,7 @@ Verilator 5.049 devel
* Fix inlining static initializer in V3Gate (#5381) (#7503). [Andrew Nolte] [Geza Lore, Testorrent USA, Inc.]
* Fix generic interface port forwarded to a nested instance (#7454) (#7457). [Yilou Wang]
* Fix internal error on multi-cycle SVA under default clocking (#7472) (#7506). [Yilou Wang]
* Fix internal error instead of missing prototype error (#7485). [Alex Solomatnikov]
* Fix mailbox#(packed_struct) type mismatch with parameterized class (#7494) (#7495). [Nikolai Kumar]
* Fix std::randomize internal error on static member of different class (#7498) (#7499). [Alex Solomatnikov]
* Fix virtual interface method call inlining and IMPURE suppression (#7505). [Nikolay Puzanov]

View File

@ -193,6 +193,7 @@ public:
void dumpSelf(const string& nameComment, bool force = false) {
if (debug() >= 6 || dumpLevel() >= 6 || force) {
const string filename = v3Global.debugFilename(nameComment) + ".txt";
UINFO(4, "Dumping " << filename);
const std::unique_ptr<std::ofstream> logp{V3File::new_ofstream(filename)};
if (logp->fail()) v3fatal("Can't write file: " << filename);
std::ostream& os = *logp;

View File

@ -207,9 +207,18 @@ public:
void importFromClass(VSymGraph* graphp, const VSymEnt* srcp) {
// Import tokens from source symbol table into this symbol table
// Used for classes in early parsing only to handle "extends"
// If an "extern foo" exists, then we can't import "foo" from the base class.
// But ok for "extern foo" and "foo" to both come from base (so must check before insert)
std::unordered_set<std::string> haveExterns;
for (IdNameMap::const_iterator it = srcp->m_idNameMap.begin();
it != srcp->m_idNameMap.end(); ++it) {
importOneSymbol(graphp, it->first, it->second, false);
if (m_idNameMap.count("extern " + it->first)) haveExterns.emplace(it->first);
}
for (IdNameMap::const_iterator it = srcp->m_idNameMap.begin();
it != srcp->m_idNameMap.end(); ++it) {
if (!haveExterns.count(it->first))
importOneSymbol(graphp, it->first, it->second, false);
}
}
void importFromPackage(VSymGraph* graphp, const VSymEnt* srcp, const string& id_or_star) {

View File

@ -0,0 +1,5 @@
%Error-PROTOTYPEMIS: t/t_class_extern_mis2_bad.v:15:21: Definition not found for extern prototype 'new'
15 | extern function new();
| ^~~
... For error description see https://verilator.org/warn/PROTOTYPEMIS?v=latest
%Error: Exiting due to

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# 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-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('linter')
test.lint(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,21 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2026 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
package s_core_env_pkg;
virtual class x_scoreboard;
extern function void has_ext_ok();
endclass
function void x_scoreboard::has_ext_ok();
endfunction
class cls_misses_new_1 extends x_scoreboard;
extern function new(); // <--- BAD
endclass
endpackage
module t;
endmodule