From f71749c3c459818d7bef8b31a9ea353645cb40dd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sun, 24 Jan 2010 20:53:24 -0500 Subject: [PATCH] Fix some MSVC++ warnings --- include/verilatedos.h | 1 + src/V3Ast.h | 4 ++-- src/V3AstNodes.h | 2 +- src/V3Case.cpp | 2 +- src/V3Cdc.cpp | 6 +++--- src/V3EmitMk.cpp | 4 ++-- src/V3Error.cpp | 2 +- src/V3File.cpp | 12 ++++++++++-- src/V3Link.cpp | 5 +++-- src/V3Number.h | 2 +- src/V3SymTable.h | 2 +- src/V3Table.cpp | 2 +- src/V3Trace.cpp | 2 +- 13 files changed, 28 insertions(+), 18 deletions(-) diff --git a/include/verilatedos.h b/include/verilatedos.h index 0e3647a45..058fffb0c 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -79,6 +79,7 @@ #ifndef VL_WARNINGS # ifdef _MSC_VER +# pragma warning(disable:4099) // C4099: type name first seen using 'class' now seen using 'struct' (V3AstNode) # pragma warning(disable:4100) // C4100: unreferenced formal parameter (L4) # pragma warning(disable:4127) // C4127: conditional expression is constant (L4) # pragma warning(disable:4146) // C4146: unary minus operator applied to unsigned type, result still unsigned diff --git a/src/V3Ast.h b/src/V3Ast.h index c02be0217..9f666bde2 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -925,7 +925,7 @@ struct AstNodeMath : public AstNode { virtual bool cleanOut() = 0; // True if output has extra upper bits zero // Someday we will generically support data types on every math node // Until then isOpaque indicates we shouldn't constant optimize this node type - bool isOpaque() { return castCvtPackString(); } + bool isOpaque() { return castCvtPackString()!=NULL; } }; struct AstNodeTermop : public AstNodeMath { @@ -1273,7 +1273,7 @@ public: // op1 = Output variable (functions only, NULL for tasks) AstNode* fvarp() const { return op1p()->castNode(); } void addFvarp(AstNode* nodep) { addNOp1p(nodep); } - bool isFunction() const { return fvarp(); } + bool isFunction() const { return fvarp()!=NULL; } // op3 = Statements/Ports/Vars AstNode* stmtsp() const { return op3p()->castNode(); } // op3 = List of statements void addStmtsp(AstNode* nodep) { addNOp3p(nodep); } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index e7e816e36..5dd5cff5c 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -96,7 +96,7 @@ public: if (m_name.length()==0) { width(1,1); // 0 width isn't allowed due to historic special cases } else { - width(m_name.length()*8, m_name.length()*8); + width(((int)m_name.length())*8, ((int)m_name.length())*8); } } ASTNODE_NODE_FUNCS(ConstString, CONSTSTRING) diff --git a/src/V3Case.cpp b/src/V3Case.cpp index bc5286126..18f049930 100644 --- a/src/V3Case.cpp +++ b/src/V3Case.cpp @@ -136,7 +136,7 @@ private: // Per-CASE int m_caseWidth; // Width of valueItems int m_caseItems; // Number of caseItem unique values - int m_caseNoOverlapsAllCovered; // Proven to be synopsys parallel_case compliant + bool m_caseNoOverlapsAllCovered; // Proven to be synopsys parallel_case compliant AstNode* m_valueItem[1<iterateChildren(*this); @@ -190,12 +190,12 @@ public: virtual ~CdcWidthVisitor() {} // ACCESSORS int maxWidth() { - int width=1; + size_t width=1; width += m_maxFilenameLen; width += 1; // The : width += cvtToStr(m_maxLineno).length(); width += 1; // Final : - return width; + return (int)width; } }; diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 8090d9da9..2c99f6f0e 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -155,7 +155,7 @@ public: of.puts("# User .cpp files (from .cpp's on Verilator command line)\n"); of.puts("VM_USER_CLASSES = \\\n"); - for (V3StringSet::iterator it = v3Global.opt.cppFiles().begin(); + for (V3StringSet::const_iterator it = v3Global.opt.cppFiles().begin(); it != v3Global.opt.cppFiles().end(); ++it) { string cppfile = *it; of.puts("\t"+V3Options::filenameNonExt(cppfile)+" \\\n"); @@ -181,7 +181,7 @@ public: of.puts("\n### Executable rules... (from --exe)\n"); of.puts("VPATH += $(VM_USER_DIR)\n"); of.puts("\n"); - for (V3StringSet::iterator it = v3Global.opt.cppFiles().begin(); + for (V3StringSet::const_iterator it = v3Global.opt.cppFiles().begin(); it != v3Global.opt.cppFiles().end(); ++it) { string cppfile = *it; string basename = V3Options::filenameNonExt(cppfile); diff --git a/src/V3Error.cpp b/src/V3Error.cpp index ca0a28cc5..c53d4f207 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -258,7 +258,7 @@ string V3Error::lineStr (const char* filename, int lineno) { if (fnslashp) filename = fnslashp+1; out<20) numsp = 20; + size_t numsp = out.str().length(); if (numsp>20) numsp = 20; out<<(spaces + numsp); return out.str(); } diff --git a/src/V3File.cpp b/src/V3File.cpp index 32904701c..64dffb0ff 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -343,7 +343,11 @@ private: int got = read (fd, buf, todo); //UINFO(9,"RD GOT g "<< got<<" e "<0) out.append(buf, got); - else if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { + else if (errno == EINTR || errno == EAGAIN +#ifdef EWOULDBLOCK + || errno == EWOULDBLOCK +#endif + ) { checkFilter(false); usleep(1000); continue; } else { m_readEof = true; break; } } @@ -372,7 +376,11 @@ private: int got = write (m_writeFd, (out.c_str())+offset, out.length()-offset); //UINFO(9,"WR GOT g "<< got<<" e "<0) offset += got; - else if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { + else if (errno == EINTR || errno == EAGAIN +#ifdef EWOULDBLOCK + || errno == EWOULDBLOCK +#endif + ) { checkFilter(false); usleep(1000); continue; } else break; diff --git a/src/V3Link.cpp b/src/V3Link.cpp index 216c3188f..104b785b3 100644 --- a/src/V3Link.cpp +++ b/src/V3Link.cpp @@ -89,10 +89,11 @@ private: // METHODS V3SymTable* symsFindNew(AstNode* nodep, V3SymTable* upperVarsp) { // Find or create symbol table for this node - if (V3SymTable* symsp = nodep->user4p()->castSymTable()) { + V3SymTable* symsp = nodep->user4p()->castSymTable(); + if (symsp) { return symsp; } else { - V3SymTable* symsp = new V3SymTable(nodep, upperVarsp); + symsp = new V3SymTable(nodep, upperVarsp); m_delSymps.push_back(symsp); nodep->user4p(symsp); return symsp; diff --git a/src/V3Number.h b/src/V3Number.h index ad9778b2c..e0e48bdab 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -91,7 +91,7 @@ private: return ( (m_value[bit/32] & (1UL<<(bit&31))) && (m_valueX[bit/32] & (1UL<<(bit&31))) ); } bool bitIsXZ(int bit) const { if (bit>=m_width) return bitIsXZ(m_width-1); - return ( (m_valueX[bit/32] & (1UL<<(bit&31))) ); + return ( (m_valueX[bit/32] & (1UL<<(bit&31))) && 1); } bool bitIsZ (int bit) const { if (bit>=m_width) return bitIsZ(m_width-1); diff --git a/src/V3SymTable.h b/src/V3SymTable.h index 3c2a24f1a..bd146ed84 100644 --- a/src/V3SymTable.h +++ b/src/V3SymTable.h @@ -109,7 +109,7 @@ class V3SymTable : public AstNUser { if (user4p_is_table) { AstUser4InUse::check(); } for (IdNameMap::const_iterator it=m_idNameMap.begin(); it!=m_idNameMap.end(); ++it) { os<first; - for (int i=it->first.length(); i<30; ++i) os<<" "; + for (size_t i=it->first.length(); i<30; ++i) os<<" "; if (user4p_is_table) { V3SymTable* belowp = (it->second)->user4p()->castSymTable(); os<second<fileline(); AstNode* condp = NULL; - for (ActCodeSet::iterator csit = actset.begin(); csit!=actset.end(); ++csit) { + for (ActCodeSet::const_iterator csit = actset.begin(); csit!=actset.end(); ++csit) { uint32_t acode = *csit; AstNode* selp = new AstSel (fl, new AstVarRef(fl, m_activityVscp, false), new AstConst(fl, acode),