diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index 7f4c57e0e..62596a32d 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -794,7 +794,7 @@ const AstNodeDType* AstNodeDType::skipRefIterp(bool skipConst, bool skipEnum) co nodep = subp; continue; } else { - v3fatalSrc("Typedef not linked"); + nodep->v3fatalSrc(nodep->prettyTypeName() << " not linked to type"); return nullptr; } } diff --git a/src/V3Error.h b/src/V3Error.h index d0a2bf77f..62cb9af52 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -564,9 +564,9 @@ void v3errorEndFatal(std::ostringstream& sstr) #define v3info(msg) v3warnCode(V3ErrorCode::EC_INFO, msg) #define v3error(msg) v3warnCode(V3ErrorCode::EC_ERROR, msg) #define v3fatal(msg) v3warnCodeFatal(V3ErrorCode::EC_FATAL, msg) -// Use this instead of fatal() if message gets suppressed with --quiet-exit +// Fatal exit; used instead of fatal() if message gets suppressed with --quiet-exit #define v3fatalExit(msg) v3warnCodeFatal(V3ErrorCode::EC_FATALEXIT, msg) -// Use this instead of fatal() to mention the source code line. +// Fatal exit; used instead of fatal() to mention the source code line #define v3fatalSrc(msg) \ v3errorEndFatal(v3errorBuildMessage( \ V3Error::v3errorPrepFileLine(V3ErrorCode::EC_FATALSRC, __FILE__, __LINE__), msg)) @@ -574,6 +574,10 @@ void v3errorEndFatal(std::ostringstream& sstr) #define v3fatalStatic(msg) \ ::v3errorEndFatal(v3errorBuildMessage(V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), msg)) +/// Print a message when debug() >= level. stmsg is stream; e.g. use as '"foo=" << foo' +// +// Requires debug() function to exist in current scope, to hack this in temporarily: +// auto debug = []() -> bool { return V3Error::debugDefault(); }; #define UINFO(level, stmsg) \ do { \ if (VL_UNCOVERABLE(debug() >= (level))) { \ @@ -585,6 +589,7 @@ void v3errorEndFatal(std::ostringstream& sstr) if (VL_UNCOVERABLE(debug() >= (level))) { std::cout << stmsg; } \ } while (false) +/// Compile statements only when debug build #ifdef VL_DEBUG #define UDEBUGONLY(stmts) \ do { stmts } while (false) @@ -595,12 +600,12 @@ void v3errorEndFatal(std::ostringstream& sstr) } while (false) #endif -// Assertion without object, generally UOBJASSERT preferred +/// Assert without error location, generally UASSERT_OBJ preferred #define UASSERT(condition, stmsg) \ do { \ if (VL_UNCOVERABLE(!(condition))) v3fatalSrc(stmsg); \ } while (false) -// Assertion with object +/// Assert with object to provide error location #define UASSERT_OBJ(condition, obj, stmsg) \ do { \ if (VL_UNCOVERABLE(!(condition))) (obj)->v3fatalSrc(stmsg); \ @@ -614,7 +619,7 @@ void v3errorEndFatal(std::ostringstream& sstr) V3Error::vlAbort(); \ } \ } while (false) -// Check self test values for expected value. Safe from side-effects. +/// Check self test values for expected value. Safe from side-effects. // Type argument can be removed when go to C++11 (use auto). #define UASSERT_SELFTEST(Type, got, exp) \ do { \ @@ -625,6 +630,7 @@ void v3errorEndFatal(std::ostringstream& sstr) << g << " expected=" << e); \ } while (false) +// Error that call not supported; only for some Ast functions #define V3ERROR_NA \ do { \ v3error("Internal: Unexpected Call"); \ diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 304bd4529..95a200463 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1692,7 +1692,6 @@ public: LinkDotFindVisitor(AstNetlist* rootp, LinkDotState* statep) : m_statep{statep} { UINFO(4, __FUNCTION__ << ": " << endl); - iterate(rootp); } ~LinkDotFindVisitor() override = default; @@ -4063,7 +4062,8 @@ class LinkDotResolveVisitor final : public VNVisitor { const AstClass* const clsp = VN_CAST(cpackagerefp->classOrPackageNodep(), Class); if (clsp && clsp->isParameterized()) { // Unable to link before the instantiation of parameter classes. - // The class reference node has to be visited to properly link parameters. + // The class reference node still has to be visited now to later link + // parameters. iterate(cpackagep); return; }