diff --git a/src/V3Error.h b/src/V3Error.h index 870893c8e..cac812106 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -417,7 +417,11 @@ inline void v3errorEndFatal(std::ostringstream& sstr) { #define VL_DEBUG_FUNC \ static int debug() { \ static int level = -1; \ - if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__); \ + if (VL_UNLIKELY(level < 0)) { \ + const int debugSrcLevel = v3Global.opt.debugSrcLevel(__FILE__); \ + if (!v3Global.opt.available()) return debugSrcLevel; \ + level = debugSrcLevel; \ + } \ return level; \ } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index f5e141701..8e52d8761 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -791,6 +791,9 @@ void V3Options::notify() { if (coverage() && savable()) { cmdfl->v3error("--coverage and --savable not supported together"); } + + // Mark options as available + m_available = true; } //###################################################################### diff --git a/src/V3Options.h b/src/V3Options.h index 3668fe605..6d42ccabe 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -361,6 +361,8 @@ private: bool m_oTable; // main switch: -Oa: lookup table creation // clang-format on + bool m_available = false; // Set to true at the end of option parsing + private: // METHODS void addArg(const string& arg); @@ -402,6 +404,7 @@ public: void addVFile(const string& filename); void addForceInc(const string& filename); void notify(); + bool available() const { return m_available; } // ACCESSORS (options) bool preprocOnly() const { return m_preprocOnly; }