Fix conflicting function/class name linking error (#6182)
This commit is contained in:
parent
826e5b0826
commit
8c5ba3a0d7
|
@ -779,14 +779,51 @@ public:
|
||||||
if (!foundp) baddot = dotname;
|
if (!foundp) baddot = dotname;
|
||||||
return foundp;
|
return foundp;
|
||||||
}
|
}
|
||||||
|
static bool checkIfClassOrPackage(const VSymEnt* const symp) {
|
||||||
|
if (VN_IS(symp->nodep(), Class) || VN_IS(symp->nodep(), Package)) return true;
|
||||||
|
const AstRefDType* refDTypep = nullptr;
|
||||||
|
if (const AstTypedef* const typedefp = VN_CAST(symp->nodep(), Typedef)) {
|
||||||
|
if (VN_IS(typedefp->childDTypep(), ClassRefDType)) return true;
|
||||||
|
if (const AstRefDType* const refp = VN_CAST(typedefp->childDTypep(), RefDType)) {
|
||||||
|
refDTypep = refp;
|
||||||
|
}
|
||||||
|
} else if (const AstParamTypeDType* const paramTypep
|
||||||
|
= VN_CAST(symp->nodep(), ParamTypeDType)) {
|
||||||
|
if (const AstRequireDType* const requireDTypep
|
||||||
|
= VN_CAST(paramTypep->childDTypep(), RequireDType)) {
|
||||||
|
if (const AstRefDType* const refp = VN_CAST(requireDTypep->lhsp(), RefDType)) {
|
||||||
|
refDTypep = refp;
|
||||||
|
} else if (VN_IS(requireDTypep->lhsp(), VoidDType)
|
||||||
|
|| VN_IS(requireDTypep->lhsp(), BasicDType)
|
||||||
|
|| VN_IS(requireDTypep->lhsp(), ClassRefDType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: this should be handled properly - case when it is known what type is
|
||||||
|
// referenced by AstRefDType (refDTypep->typeofp() is null or
|
||||||
|
// refDTypep->classOrPackageOpp() is null)
|
||||||
|
if (refDTypep && !refDTypep->typeofp() && !refDTypep->classOrPackageOpp()) {
|
||||||
|
// When still unknown - return because it may be a class, classes may not be
|
||||||
|
// linked at this point. Return in case it gets resolved to a class in the future
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
VSymEnt* resolveClassOrPackage(VSymEnt* lookSymp, AstClassOrPackageRef* nodep, bool fallback,
|
VSymEnt* resolveClassOrPackage(VSymEnt* lookSymp, AstClassOrPackageRef* nodep, bool fallback,
|
||||||
bool classOnly, const string& forWhat) {
|
bool classOnly, const string& forWhat) {
|
||||||
if (nodep->classOrPackageSkipp()) return getNodeSym(nodep->classOrPackageSkipp());
|
if (nodep->classOrPackageSkipp()) return getNodeSym(nodep->classOrPackageSkipp());
|
||||||
VSymEnt* foundp;
|
VSymEnt* foundp;
|
||||||
if (fallback) {
|
if (fallback) {
|
||||||
foundp = lookSymp->findIdFallback(nodep->name());
|
VSymEnt* currentLookSymp = lookSymp;
|
||||||
|
do {
|
||||||
|
foundp = currentLookSymp->findIdFlat(nodep->name());
|
||||||
|
if (foundp && !checkIfClassOrPackage(foundp)) foundp = nullptr;
|
||||||
|
if (!foundp) currentLookSymp = currentLookSymp->fallbackp();
|
||||||
|
} while (!foundp && currentLookSymp);
|
||||||
} else {
|
} else {
|
||||||
foundp = lookSymp->findIdFlat(nodep->name());
|
foundp = lookSymp->findIdFlat(nodep->name());
|
||||||
|
if (foundp && !checkIfClassOrPackage(foundp)) foundp = nullptr;
|
||||||
}
|
}
|
||||||
if (!foundp && v3Global.rootp()->stdPackagep()) { // Look under implied std::
|
if (!foundp && v3Global.rootp()->stdPackagep()) { // Look under implied std::
|
||||||
foundp = getNodeSym(v3Global.rootp()->stdPackagep())->findIdFlat(nodep->name());
|
foundp = getNodeSym(v3Global.rootp()->stdPackagep())->findIdFlat(nodep->name());
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2025 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
|
||||||
|
|
||||||
|
import vltest_bootstrap
|
||||||
|
|
||||||
|
test.scenarios('simulator')
|
||||||
|
|
||||||
|
test.compile()
|
||||||
|
|
||||||
|
test.passes()
|
|
@ -0,0 +1,17 @@
|
||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||||
|
// any use, without warranty, 2025 by Antmicro.
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
class setup_coefficients;
|
||||||
|
static function int create();
|
||||||
|
return 1;
|
||||||
|
endfunction
|
||||||
|
endclass
|
||||||
|
|
||||||
|
class biquad_vseq;
|
||||||
|
int c_setup = setup_coefficients::create();
|
||||||
|
function void setup_coefficients();
|
||||||
|
endfunction
|
||||||
|
endclass: biquad_vseq
|
Loading…
Reference in New Issue