Fix Visual Studio compiler issues (#2375)
* Make sure compiler creates same object file as target of rule * MSVC requires a string return * Case ranges are a gnu extension which MSVC does not understand * _dupenv_s also returns 0 if the var could not be found See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/dupenv-s-wdupenv-s?view=vs-2019
This commit is contained in:
parent
15f0f967b3
commit
e8f27be200
|
|
@ -681,7 +681,16 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
|||
inPct = false;
|
||||
char fmt = pos[0];
|
||||
switch (fmt) {
|
||||
case '0' ... '9':
|
||||
case '0': // FALLTHRU
|
||||
case '1': // FALLTHRU
|
||||
case '2': // FALLTHRU
|
||||
case '3': // FALLTHRU
|
||||
case '4': // FALLTHRU
|
||||
case '5': // FALLTHRU
|
||||
case '6': // FALLTHRU
|
||||
case '7': // FALLTHRU
|
||||
case '8': // FALLTHRU
|
||||
case '9':
|
||||
inPct = true; // Get more digits
|
||||
widthSet = true;
|
||||
width = width * 10 + (fmt - '0');
|
||||
|
|
|
|||
|
|
@ -288,21 +288,21 @@ V3Number_test: V3Number_test.o
|
|||
$(PERL) $(ASTGEN) -I$(srcdir) $*.cpp
|
||||
|
||||
%.o: %.cpp
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSWALL} -c $<
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSWALL} -c $< -o $@
|
||||
%.o: %.c
|
||||
$(OBJCACHE) ${CC} ${CFLAGS} ${CPPFLAGSWALL} -c $<
|
||||
$(OBJCACHE) ${CC} ${CFLAGS} ${CPPFLAGSWALL} -c $< -o $@
|
||||
|
||||
V3ParseLex.o: V3ParseLex.cpp V3Lexer.yy.cpp V3ParseBison.c
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $<
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $< -o $@
|
||||
|
||||
V3ParseGrammar.o: V3ParseGrammar.cpp V3ParseBison.c
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $<
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $< -o $@
|
||||
|
||||
V3ParseImp.o: V3ParseImp.cpp V3ParseBison.c
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $<
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $< -o $@
|
||||
|
||||
V3PreProc.o: V3PreProc.cpp V3PreLex.yy.cpp
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $<
|
||||
$(OBJCACHE) ${CXX} ${CXXFLAGS} ${CPPFLAGSPARSER} -c $< -o $@
|
||||
|
||||
#### Generated files
|
||||
|
||||
|
|
|
|||
|
|
@ -7657,7 +7657,7 @@ public:
|
|||
V3ERROR_NA;
|
||||
}
|
||||
virtual string emitVerilog() { return "%k%l[%r]"; }
|
||||
virtual string emitC() { V3ERROR_NA; }
|
||||
virtual string emitC() { V3ERROR_NA_RETURN(""); }
|
||||
virtual string emitSimpleOperator() { return ""; }
|
||||
virtual bool cleanOut() const { return true; }
|
||||
virtual bool cleanLhs() const { return true; }
|
||||
|
|
|
|||
|
|
@ -2162,7 +2162,16 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep, const str
|
|||
} else { // Format character
|
||||
inPct = false;
|
||||
switch (tolower(pos[0])) {
|
||||
case '0' ... '9':
|
||||
case '0': // FALLTHRU
|
||||
case '1': // FALLTHRU
|
||||
case '2': // FALLTHRU
|
||||
case '3': // FALLTHRU
|
||||
case '4': // FALLTHRU
|
||||
case '5': // FALLTHRU
|
||||
case '6': // FALLTHRU
|
||||
case '7': // FALLTHRU
|
||||
case '8': // FALLTHRU
|
||||
case '9': // FALLTHRU
|
||||
case '.': // FALLTHRU
|
||||
case '-':
|
||||
// Digits, like %5d, etc.
|
||||
|
|
|
|||
|
|
@ -364,7 +364,16 @@ private:
|
|||
} else if (inpercent) {
|
||||
inpercent = 0;
|
||||
switch (c) {
|
||||
case '0' ... '9':
|
||||
case '0': // FALLTHRU
|
||||
case '1': // FALLTHRU
|
||||
case '2': // FALLTHRU
|
||||
case '3': // FALLTHRU
|
||||
case '4': // FALLTHRU
|
||||
case '5': // FALLTHRU
|
||||
case '6': // FALLTHRU
|
||||
case '7': // FALLTHRU
|
||||
case '8': // FALLTHRU
|
||||
case '9': // FALLTHRU
|
||||
case '.': inpercent = true; break;
|
||||
case '%': break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -203,7 +203,16 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
|||
int got_01 = 0;
|
||||
for (const char* cp = value_startp; *cp; cp++) {
|
||||
switch (tolower(*cp)) {
|
||||
case '0' ... '9': {
|
||||
case '0': // FALLTHRU
|
||||
case '1': // FALLTHRU
|
||||
case '2': // FALLTHRU
|
||||
case '3': // FALLTHRU
|
||||
case '4': // FALLTHRU
|
||||
case '5': // FALLTHRU
|
||||
case '6': // FALLTHRU
|
||||
case '7': // FALLTHRU
|
||||
case '8': // FALLTHRU
|
||||
case '9': {
|
||||
if (olen <= 7) { // 10000000 fits in 32 bits, so ok
|
||||
// Constants are common, so for speed avoid wide math until we need it
|
||||
val = val * 10 + (*cp - '0');
|
||||
|
|
|
|||
|
|
@ -65,8 +65,9 @@
|
|||
string V3Os::getenvStr(const string& envvar, const string& defaultValue) {
|
||||
#if defined(_MSC_VER)
|
||||
// Note: MinGW does not offer _dupenv_s
|
||||
char* envvalue;
|
||||
if (_dupenv_s(&envvalue, nullptr, envvar.c_str()) == 0) {
|
||||
char* envvalue = nullptr;
|
||||
_dupenv_s(&envvalue, nullptr, envvar.c_str());
|
||||
if (envvalue != nullptr) {
|
||||
const std::string result{envvalue};
|
||||
free(envvalue);
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue