Fix some MSVC++ warnings

This commit is contained in:
Wilson Snyder 2010-01-24 20:53:24 -05:00
parent cbc90e7ffb
commit f71749c3c4
13 changed files with 28 additions and 18 deletions

View File

@ -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

View File

@ -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); }

View File

@ -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)

View File

@ -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<<CASE_OVERLAP_WIDTH]; // For each possible value, the case branch we need
// METHODS

View File

@ -168,7 +168,7 @@ public:
class CdcWidthVisitor : public CdcBaseVisitor {
private:
int m_maxLineno;
unsigned m_maxFilenameLen;
size_t m_maxFilenameLen;
virtual void visit(AstNode* nodep, AstNUser*) {
nodep->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;
}
};

View File

@ -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);

View File

@ -258,7 +258,7 @@ string V3Error::lineStr (const char* filename, int lineno) {
if (fnslashp) filename = fnslashp+1;
out<<filename<<":"<<dec<<lineno<<":";
const char* spaces = " ";
int numsp = out.str().length(); if (numsp>20) numsp = 20;
size_t numsp = out.str().length(); if (numsp>20) numsp = 20;
out<<(spaces + numsp);
return out.str();
}

View File

@ -343,7 +343,11 @@ private:
int got = read (fd, buf, todo);
//UINFO(9,"RD GOT g "<< got<<" e "<<errno<<" "<<strerror(errno)<<endl); usleep(50*1000);
if (got>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 "<<errno<<" "<<strerror(errno)<<endl); usleep(50*1000);
if (got>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;

View File

@ -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;

View File

@ -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);

View File

@ -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<<indent<<it->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<<setw(10)<<(void*)(belowp)<<setw(0)<<" "<<it->second<<endl;

View File

@ -123,7 +123,7 @@ private:
// Also sets m_outVarps
// Calc data storage in bytes
int chgWidth = m_outVarps.size(); // Width of one change-it-vector
size_t chgWidth = m_outVarps.size(); // Width of one change-it-vector
if (chgWidth<8) chgWidth = 8;
double space = (pow((double)2,((double)(m_inWidth)))
*(double)(m_outWidth+chgWidth));

View File

@ -449,7 +449,7 @@ private:
// Build a new IF statement
FileLine* fl = addp->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),