From 7b073fec7d9974450c72ebd8facd1873ce27e64f Mon Sep 17 00:00:00 2001 From: Kritik Bhimani Date: Tue, 13 Dec 2022 05:15:32 +0530 Subject: [PATCH] Fix MSVC++ portability issues (#3812) --- include/verilatedos.h | 2 +- src/V3DfgDfgToAst.cpp | 8 ++++++++ src/V3Os.cpp | 4 ++-- src/bisonpre | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/verilatedos.h b/include/verilatedos.h index 72f80d0e7..d5906b526 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -234,7 +234,7 @@ //========================================================================= // C++-2011 -#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(VL_CPPCHECK) +#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(VL_CPPCHECK) || (defined(_MSC_VER) && _MSC_VER >= 1900) #else # error "Verilator requires a C++11 or newer compiler" #endif diff --git a/src/V3DfgDfgToAst.cpp b/src/V3DfgDfgToAst.cpp index 9075858d5..cd32b3fcb 100644 --- a/src/V3DfgDfgToAst.cpp +++ b/src/V3DfgDfgToAst.cpp @@ -100,21 +100,29 @@ AstShiftRS* makeNode( // template <> AstCCast* makeNode(const DfgCCast* vtxp, AstNodeExpr*) { vtxp->v3fatalSrc("not implemented"); + VL_UNREACHABLE; + return nullptr; // LCOV_EXCL_LINE } template <> AstAtoN* makeNode(const DfgAtoN* vtxp, AstNodeExpr*) { vtxp->v3fatalSrc("not implemented"); + VL_UNREACHABLE; + return nullptr; // LCOV_EXCL_LINE } template <> AstCompareNN* makeNode(const DfgCompareNN* vtxp, AstNodeExpr*, AstNodeExpr*) { vtxp->v3fatalSrc("not implemented"); + VL_UNREACHABLE; + return nullptr; // LCOV_EXCL_LINE } template <> AstSliceSel* makeNode( const DfgSliceSel* vtxp, AstNodeExpr*, AstNodeExpr*, AstNodeExpr*) { vtxp->v3fatalSrc("not implemented"); + VL_UNREACHABLE; + return nullptr; // LCOV_EXCL_LINE } // LCOV_EXCL_STOP diff --git a/src/V3Os.cpp b/src/V3Os.cpp index 1bd78f583..78caceacb 100644 --- a/src/V3Os.cpp +++ b/src/V3Os.cpp @@ -80,10 +80,10 @@ string V3Os::getenvStr(const string& envvar, const string& defaultValue) { #if defined(_MSC_VER) // Note: MinGW does not offer _dupenv_s const char* envvalue = nullptr; - _dupenv_s(&envvalue, nullptr, envvar.c_str()); + _dupenv_s((char **)&envvalue, nullptr, envvar.c_str()); if (envvalue != nullptr) { const std::string result{envvalue}; - free(envvalue); + free((void *)envvalue); ret = result; } else { ret = defaultValue; diff --git a/src/bisonpre b/src/bisonpre index 664684c06..368f1c81b 100755 --- a/src/bisonpre +++ b/src/bisonpre @@ -45,7 +45,7 @@ def process(): if status != 0: unlink_outputs() sys.exit("bisonpre: %Error: " + Args.yacc + " version " + - Bison_Version + " run failed due to errors\n") + str(Bison_Version) + " run failed due to errors\n") clean_output(tmp_prefix() + ".output", output_prefix() + ".output", True, False)