Fix some MSVC warnings.

This commit is contained in:
Wilson Snyder 2022-12-22 12:19:09 -05:00
parent 71d29a235f
commit d64971ba35
4 changed files with 14 additions and 12 deletions

View File

@ -1383,7 +1383,7 @@ static IData getLine(std::string& str, IData fpi, size_t maxLen) VL_MT_SAFE {
str.push_back(c); str.push_back(c);
if (c == '\n') break; if (c == '\n') break;
} }
return str.size(); return static_cast<IData>(str.size());
} }
IData VL_FGETS_IXI(int obits, void* destp, IData fpi) VL_MT_SAFE { IData VL_FGETS_IXI(int obits, void* destp, IData fpi) VL_MT_SAFE {
@ -1633,12 +1633,12 @@ std::string VL_STACKTRACE_N() VL_MT_SAFE {
static VerilatedMutex s_stackTraceMutex; static VerilatedMutex s_stackTraceMutex;
const VerilatedLockGuard lock{s_stackTraceMutex}; const VerilatedLockGuard lock{s_stackTraceMutex};
constexpr int BT_BUF_SIZE = 100;
void* buffer[BT_BUF_SIZE];
int nptrs = 0; int nptrs = 0;
char** strings = nullptr; char** strings = nullptr;
#ifdef _VL_HAVE_STACKTRACE #ifdef _VL_HAVE_STACKTRACE
constexpr int BT_BUF_SIZE = 100;
void* buffer[BT_BUF_SIZE];
nptrs = backtrace(buffer, BT_BUF_SIZE); nptrs = backtrace(buffer, BT_BUF_SIZE);
strings = backtrace_symbols(buffer, nptrs); strings = backtrace_symbols(buffer, nptrs);
#endif #endif
@ -2569,7 +2569,7 @@ std::pair<int, char**> VerilatedContextImp::argc_argv() VL_MT_SAFE_EXCLUDES(m_ar
static char** s_argvp = nullptr; static char** s_argvp = nullptr;
if (VL_UNLIKELY(!s_loaded)) { if (VL_UNLIKELY(!s_loaded)) {
s_loaded = true; s_loaded = true;
s_argc = m_args.m_argVec.size(); s_argc = static_cast<int>(m_args.m_argVec.size());
s_argvp = new char*[s_argc + 1]; s_argvp = new char*[s_argc + 1];
int in = 0; int in = 0;
for (const auto& i : m_args.m_argVec) { for (const auto& i : m_args.m_argVec) {

View File

@ -2208,7 +2208,7 @@ inline std::string VL_REPLICATEN_NNI(const std::string& lhs, IData rep) VL_PURE
return VL_REPLICATEN_NNQ(lhs, rep); return VL_REPLICATEN_NNQ(lhs, rep);
} }
inline IData VL_LEN_IN(const std::string& ld) { return ld.length(); } inline IData VL_LEN_IN(const std::string& ld) { return static_cast<IData>(ld.length()); }
extern std::string VL_TOLOWER_NN(const std::string& ld) VL_PURE; extern std::string VL_TOLOWER_NN(const std::string& ld) VL_PURE;
extern std::string VL_TOUPPER_NN(const std::string& ld) VL_PURE; extern std::string VL_TOUPPER_NN(const std::string& ld) VL_PURE;

View File

@ -527,7 +527,7 @@ void VerilatedVcd::declare(uint32_t code, const char* name, const char* wirep, b
std::strlen(buf)); // Code (overwrite separator if isBit) std::strlen(buf)); // Code (overwrite separator if isBit)
entryp[length + !isBit] = '\n'; // Replace '\0' with line termination '\n' entryp[length + !isBit] = '\n'; // Replace '\0' with line termination '\n'
// Set length of suffix (used to increment write pointer) // Set length of suffix (used to increment write pointer)
entryp[VL_TRACE_SUFFIX_ENTRY_SIZE - 1] = !isBit + length + 1; entryp[VL_TRACE_SUFFIX_ENTRY_SIZE - 1] = static_cast<char>(length + !isBit + 1);
decl += " "; decl += " ";
decl += basename; decl += basename;
if (array) { if (array) {

View File

@ -431,11 +431,12 @@ inline void v3errorEndFatal(std::ostringstream& sstr) {
return value return value
// Helper macros for VL_DEFINE_DEBUG_FUNCTIONS // Helper macros for VL_DEFINE_DEBUG_FUNCTIONS
#define VL_DEFINE_DEBUG(name) \ // Takes an optional "name" (as __VA_ARGS__)
VL_ATTR_UNUSED static int debug##name() { \ #define VL_DEFINE_DEBUG(...) \
VL_ATTR_UNUSED static int debug##__VA_ARGS__() { \
static int level = -1; \ static int level = -1; \
if (VL_UNLIKELY(level < 0)) { \ if (VL_UNLIKELY(level < 0)) { \
std::string tag{VL_STRINGIFY(name)}; \ std::string tag{VL_STRINGIFY(__VA_ARGS__)}; \
tag[0] = std::tolower(tag[0]); \ tag[0] = std::tolower(tag[0]); \
const unsigned debugTag = v3Global.opt.debugLevel(tag); \ const unsigned debugTag = v3Global.opt.debugLevel(tag); \
const unsigned debugSrc = v3Global.opt.debugSrcLevel(__FILE__); \ const unsigned debugSrc = v3Global.opt.debugSrcLevel(__FILE__); \
@ -447,11 +448,12 @@ inline void v3errorEndFatal(std::ostringstream& sstr) {
} \ } \
static_assert(true, "") static_assert(true, "")
#define VL_DEFINE_DUMP(name) \ // Takes an optional "name" (as __VA_ARGS__)
VL_ATTR_UNUSED static int dump##name() { \ #define VL_DEFINE_DUMP(...) \
VL_ATTR_UNUSED static int dump##__VA_ARGS__() { \
static int level = -1; \ static int level = -1; \
if (VL_UNLIKELY(level < 0)) { \ if (VL_UNLIKELY(level < 0)) { \
std::string tag{VL_STRINGIFY(name)}; \ std::string tag{VL_STRINGIFY(__VA_ARGS__)}; \
tag[0] = std::tolower(tag[0]); \ tag[0] = std::tolower(tag[0]); \
const unsigned dumpTag = v3Global.opt.dumpLevel(tag); \ const unsigned dumpTag = v3Global.opt.dumpLevel(tag); \
const unsigned dumpSrc = v3Global.opt.dumpSrcLevel(__FILE__); \ const unsigned dumpSrc = v3Global.opt.dumpSrcLevel(__FILE__); \