Internals: Fix cppcheck warnings; no functional change intended

This commit is contained in:
Wilson Snyder 2011-08-04 21:58:45 -04:00
parent c83f2a4abd
commit df1da3dda9
35 changed files with 151 additions and 81 deletions

View File

@ -371,6 +371,15 @@ endif
# VERILATOR_AUTHOR_SITE # VERILATOR_AUTHOR_SITE
endif endif
CPPCHECK = cppcheck
CPPCHECK_FLAGS = --enable=all --inline-suppr --suppress=unusedScopedObject
CPPCHECK_CPP = $(wildcard $(srcdir)/include/*.cpp $(srcdir)/src/*.cpp)
CPPCHECK_DEP = $(subst .cpp,.cppcheck,$(CPPCHECK_CPP))
cppcheck: $(CPPCHECK_DEP)
%.cppcheck: %.cpp
$(CPPCHECK) $(CPPCHECK_FLAGS) -DVL_DEBUG=1 -I$(srcdir)/include -I$(srcdir)/src $<
ftp: info ftp: info
install-msg: install-msg:

View File

@ -1079,6 +1079,7 @@ VerilatedScope::VerilatedScope() {
m_callbacksp = NULL; m_callbacksp = NULL;
m_namep = NULL; m_namep = NULL;
m_funcnumMax = 0; m_funcnumMax = 0;
m_symsp = NULL;
m_varsp = NULL; m_varsp = NULL;
} }

View File

@ -110,6 +110,7 @@ private:
void dumpHeader(); void dumpHeader();
void dumpPrep (vluint64_t timeui); void dumpPrep (vluint64_t timeui);
void dumpFull (vluint64_t timeui); void dumpFull (vluint64_t timeui);
// cppcheck-suppress functionConst
void dumpDone (); void dumpDone ();
inline void printCode (vluint32_t code) { inline void printCode (vluint32_t code) {
if (code>=(94*94*94)) *m_writep++ = ((char)((code/94/94/94)%94+33)); if (code>=(94*94*94)) *m_writep++ = ((char)((code/94/94/94)%94+33));
@ -117,7 +118,7 @@ private:
if (code>=(94)) *m_writep++ = ((char)((code/94)%94+33)); if (code>=(94)) *m_writep++ = ((char)((code/94)%94+33));
*m_writep++ = ((char)((code)%94+33)); *m_writep++ = ((char)((code)%94+33));
} }
string stringCode (vluint32_t code) { static string stringCode (vluint32_t code) {
string out; string out;
if (code>=(94*94*94)) out += ((char)((code/94/94/94)%94+33)); if (code>=(94*94*94)) out += ((char)((code/94/94/94)%94+33));
if (code>=(94*94)) out += ((char)((code/94/94)%94+33)); if (code>=(94*94)) out += ((char)((code/94/94)%94+33));
@ -141,6 +142,8 @@ public:
m_evcd = false; m_evcd = false;
m_scopeEscape = '.'; // Backward compatibility m_scopeEscape = '.'; // Backward compatibility
m_wroteBytes = 0; m_wroteBytes = 0;
m_fd = 0;
m_fullDump = true;
} }
~VerilatedVcd(); ~VerilatedVcd();

View File

@ -98,7 +98,9 @@ class VerilatedVpioCb : public VerilatedVpio {
s_vpi_value m_value; s_vpi_value m_value;
QData m_time; QData m_time;
public: public:
VerilatedVpioCb(const t_cb_data* cbDatap, QData time) : m_cbData(*cbDatap), m_time(time) { // cppcheck-suppress uninitVar // m_value
VerilatedVpioCb(const t_cb_data* cbDatap, QData time)
: m_cbData(*cbDatap), m_time(time) {
m_cbData.value = &m_value; m_cbData.value = &m_value;
} }
virtual ~VerilatedVpioCb() {} virtual ~VerilatedVpioCb() {}

View File

@ -148,7 +148,11 @@ public:
} }
public: public:
// CONSTUCTORS // CONSTUCTORS
ActiveNamer() {} ActiveNamer() {
m_scopep = NULL;
m_iActivep = NULL;
m_cActivep = NULL;
}
virtual ~ActiveNamer() {} virtual ~ActiveNamer() {}
void main(AstScope* nodep) { void main(AstScope* nodep) {
nodep->accept(*this); nodep->accept(*this);

View File

@ -430,7 +430,7 @@ void AstNode::replaceWith(AstNode* newp) {
repHandle.relink(newp); repHandle.relink(newp);
} }
void AstNRelinker::dump(ostream& str) { void AstNRelinker::dump(ostream& str) const {
str<<" BK="<<(uint32_t*)m_backp; str<<" BK="<<(uint32_t*)m_backp;
str<<" ITER="<<(uint32_t*)m_iterpp; str<<" ITER="<<(uint32_t*)m_iterpp;
str<<" CHG="<<(m_chg==RELINK_NEXT?"[NEXT] ":""); str<<" CHG="<<(m_chg==RELINK_NEXT?"[NEXT] ":"");
@ -947,7 +947,7 @@ void AstNode::checkTree() {
} }
} }
void AstNode::dumpPtrs(ostream& os) { void AstNode::dumpPtrs(ostream& os) const {
os<<"This="<<typeName()<<" "<<(void*)this; os<<"This="<<typeName()<<" "<<(void*)this;
os<<" back="<<(void*)backp(); os<<" back="<<(void*)backp();
if (nextp()) os<<" next="<<(void*)nextp(); if (nextp()) os<<" next="<<(void*)nextp();

View File

@ -71,7 +71,7 @@ public:
}; };
return names[m_e]; return names[m_e];
}; };
inline AstNumeric () {} inline AstNumeric () : m_e(UNSIGNED) {}
inline AstNumeric (en _e) : m_e(_e) {} inline AstNumeric (en _e) : m_e(_e) {}
explicit inline AstNumeric (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstNumeric (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -89,6 +89,7 @@ public:
class AstPragmaType { class AstPragmaType {
public: public:
enum en { enum en {
ILLEGAL,
COVERAGE_BLOCK_OFF, COVERAGE_BLOCK_OFF,
INLINE_MODULE, INLINE_MODULE,
NO_INLINE_MODULE, NO_INLINE_MODULE,
@ -97,7 +98,7 @@ public:
PUBLIC_TASK PUBLIC_TASK
}; };
enum en m_e; enum en m_e;
inline AstPragmaType () {} inline AstPragmaType () : m_e(ILLEGAL) {}
inline AstPragmaType (en _e) : m_e(_e) {} inline AstPragmaType (en _e) : m_e(_e) {}
explicit inline AstPragmaType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstPragmaType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -120,7 +121,7 @@ public:
TRACE_CHANGE_SUB TRACE_CHANGE_SUB
}; };
enum en m_e; enum en m_e;
inline AstCFuncType () {} inline AstCFuncType () : m_e(FT_NORMAL) {}
inline AstCFuncType (en _e) : m_e(_e) {} inline AstCFuncType (en _e) : m_e(_e) {}
explicit inline AstCFuncType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstCFuncType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -188,7 +189,7 @@ public:
}; };
return names[m_e]; return names[m_e];
}; };
inline AstEdgeType () {} inline AstEdgeType () : m_e(ET_ILLEGAL) {}
inline AstEdgeType (en _e) : m_e(_e) {} inline AstEdgeType (en _e) : m_e(_e) {}
explicit inline AstEdgeType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -202,6 +203,7 @@ public:
class AstAttrType { class AstAttrType {
public: public:
enum en { enum en {
ILLEGAL,
EXPR_BITS, // V3Const converts to constant EXPR_BITS, // V3Const converts to constant
// //
VAR_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes VAR_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes
@ -217,14 +219,14 @@ public:
enum en m_e; enum en m_e;
const char* ascii() const { const char* ascii() const {
static const char* names[] = { static const char* names[] = {
"EXPR_BITS", "VAR_BASE", "%E-AT", "EXPR_BITS", "VAR_BASE",
"VAR_CLOCK", "VAR_CLOCK_ENABLE", "VAR_PUBLIC", "VAR_CLOCK", "VAR_CLOCK_ENABLE", "VAR_PUBLIC",
"VAR_PUBLIC_FLAT", "VAR_PUBLIC_FLAT_RD","VAR_PUBLIC_FLAT_RW", "VAR_PUBLIC_FLAT", "VAR_PUBLIC_FLAT_RD","VAR_PUBLIC_FLAT_RW",
"VAR_ISOLATE_ASSIGNMENTS", "VAR_SFORMAT" "VAR_ISOLATE_ASSIGNMENTS", "VAR_SFORMAT"
}; };
return names[m_e]; return names[m_e];
}; };
inline AstAttrType () {} inline AstAttrType () : m_e(ILLEGAL) {}
inline AstAttrType (en _e) : m_e(_e) {} inline AstAttrType (en _e) : m_e(_e) {}
explicit inline AstAttrType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstAttrType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -238,6 +240,7 @@ public:
class AstBasicDTypeKwd { class AstBasicDTypeKwd {
public: public:
enum en { enum en {
UNKNOWN,
BIT, BYTE, CHANDLE, INT, INTEGER, LOGIC, LONGINT, BIT, BYTE, CHANDLE, INT, INTEGER, LOGIC, LONGINT,
DOUBLE, SHORTINT, FLOAT, TIME, DOUBLE, SHORTINT, FLOAT, TIME,
// Closer to a class type, but limited usage // Closer to a class type, but limited usage
@ -250,6 +253,7 @@ public:
enum en m_e; enum en m_e;
const char* ascii() const { const char* ascii() const {
static const char* names[] = { static const char* names[] = {
"%E-unk",
"bit", "byte", "chandle", "int", "integer", "logic", "longint", "bit", "byte", "chandle", "int", "integer", "logic", "longint",
"real", "shortint", "shortreal", "time", "real", "shortint", "shortreal", "time",
"string", "string",
@ -260,6 +264,7 @@ public:
}; };
const char* dpiType() const { const char* dpiType() const {
static const char* names[] = { static const char* names[] = {
"%E-unk",
"unsigned char", "char", "void*", "int", "int", "svLogic", "long long", "unsigned char", "char", "void*", "int", "int", "svLogic", "long long",
"double", "short int", "float", "long long", "double", "short int", "float", "long long",
"const char*", "const char*",
@ -268,7 +273,7 @@ public:
}; };
return names[m_e]; return names[m_e];
}; };
inline AstBasicDTypeKwd () {} inline AstBasicDTypeKwd () : m_e(UNKNOWN) {}
inline AstBasicDTypeKwd (en _e) : m_e(_e) {} inline AstBasicDTypeKwd (en _e) : m_e(_e) {}
explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -351,7 +356,7 @@ public:
XTEMP XTEMP
}; };
enum en m_e; enum en m_e;
inline AstVarType () {} inline AstVarType () : m_e(UNKNOWN) {}
inline AstVarType (en _e) : m_e(_e) {} inline AstVarType (en _e) : m_e(_e) {}
explicit inline AstVarType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstVarType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -409,7 +414,7 @@ public:
CT_CASEZ CT_CASEZ
}; };
enum en m_e; enum en m_e;
inline AstCaseType () {} inline AstCaseType () : m_e(CT_CASE) {}
inline AstCaseType (en _e) : m_e(_e) {} inline AstCaseType (en _e) : m_e(_e) {}
explicit inline AstCaseType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstCaseType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -431,7 +436,7 @@ public:
DT_FATAL DT_FATAL
}; };
enum en m_e; enum en m_e;
inline AstDisplayType () {} inline AstDisplayType () : m_e(DT_DISPLAY) {}
inline AstDisplayType (en _e) : m_e(_e) {} inline AstDisplayType (en _e) : m_e(_e) {}
explicit inline AstDisplayType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline AstDisplayType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }
@ -641,7 +646,7 @@ public:
AstNRelinker() { m_backp=NULL; m_chg=RELINK_BAD; m_iterpp=NULL;} AstNRelinker() { m_backp=NULL; m_chg=RELINK_BAD; m_iterpp=NULL;}
void relink(AstNode* newp); void relink(AstNode* newp);
AstNode* oldp() const { return m_oldp; } AstNode* oldp() const { return m_oldp; }
void dump(ostream& str=cout); void dump(ostream& str=cout) const;
}; };
inline ostream& operator<<(ostream& os, AstNRelinker& rhs) { rhs.dump(os); return os;} inline ostream& operator<<(ostream& os, AstNRelinker& rhs) { rhs.dump(os); return os;}
@ -754,6 +759,7 @@ class AstNode {
void deleteTreeIter(); void deleteTreeIter();
void deleteNode(); void deleteNode();
static void relinkOneLink(AstNode*& pointpr, AstNode* newp); static void relinkOneLink(AstNode*& pointpr, AstNode* newp);
// cppcheck-suppress functionConst
void debugTreeChange(const char* prefix, int lineno, bool next); void debugTreeChange(const char* prefix, int lineno, bool next);
protected: protected:
@ -945,7 +951,7 @@ public:
bool sameTree(AstNode* node2p); // Does tree of this == node2p? bool sameTree(AstNode* node2p); // Does tree of this == node2p?
void deleteTree(); // Always deletes the next link void deleteTree(); // Always deletes the next link
void checkTree(); // User Interface version void checkTree(); // User Interface version
void dumpPtrs(ostream& str=cout); void dumpPtrs(ostream& str=cout) const;
void dumpTree(ostream& str=cout, const string& indent=" ", int maxDepth=0); void dumpTree(ostream& str=cout, const string& indent=" ", int maxDepth=0);
void dumpTreeAndNext(ostream& str=cout, const string& indent=" ", int maxDepth=0); void dumpTreeAndNext(ostream& str=cout, const string& indent=" ", int maxDepth=0);
void dumpTreeFile(const string& filename, bool append=false); void dumpTreeFile(const string& filename, bool append=false);
@ -1012,6 +1018,7 @@ struct AstNodeTermop : public AstNodeMath {
ASTNODE_BASE_FUNCS(NodeTermop) ASTNODE_BASE_FUNCS(NodeTermop)
// Know no children, and hot function, so skip iterator for speed // Know no children, and hot function, so skip iterator for speed
// See checkTreeIter also that asserts no children // See checkTreeIter also that asserts no children
// cppcheck-suppress functionConst
void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { } void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { }
}; };
@ -1274,6 +1281,7 @@ public:
void packagep(AstPackage* nodep) { m_packagep=nodep; } void packagep(AstPackage* nodep) { m_packagep=nodep; }
// Know no children, and hot function, so skip iterator for speed // Know no children, and hot function, so skip iterator for speed
// See checkTreeIter also that asserts no children // See checkTreeIter also that asserts no children
// cppcheck-suppress functionConst
void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { } void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { }
}; };

View File

@ -461,10 +461,10 @@ public:
virtual V3Hash sameHash() const { return V3Hash(); } virtual V3Hash sameHash() const { return V3Hash(); }
virtual bool same(AstNode* samep) const { return true; } virtual bool same(AstNode* samep) const { return true; }
virtual int instrCount() const { return widthInstrs(); } virtual int instrCount() const { return widthInstrs(); }
unsigned length() { return m_length; } unsigned length() const { return m_length; }
void length(unsigned length) { m_length = length; } void length(unsigned length) { m_length = length; }
void start(unsigned start) { m_start = start; } void start(unsigned start) { m_start = start; }
unsigned start() { return m_start; } unsigned start() const { return m_start; }
// Special operators // Special operators
static int dimension(AstNode* nodep); ///< How many dimensions is this reference from the base variable? static int dimension(AstNode* nodep); ///< How many dimensions is this reference from the base variable?
static AstNode* baseFromp(AstNode* nodep); ///< What is the base variable (or const) this dereferences? static AstNode* baseFromp(AstNode* nodep); ///< What is the base variable (or const) this dereferences?

View File

@ -315,6 +315,7 @@ public:
m_exprp = exprp; m_exprp = exprp;
m_original = original; m_original = original;
m_state = STATE_UNKNOWN; m_state = STATE_UNKNOWN;
m_cloning = false;
if (debug()>=9) nodep->dumpTree(cout," GateBodyIn: "); if (debug()>=9) nodep->dumpTree(cout," GateBodyIn: ");
nodep->bodysp()->iterateAndNext(*this); nodep->bodysp()->iterateAndNext(*this);
if (debug()>=9) nodep->dumpTree(cout," GateBodyOut: "); if (debug()>=9) nodep->dumpTree(cout," GateBodyOut: ");

View File

@ -146,7 +146,9 @@ private:
} }
public: public:
// CONSTRUCTORS // CONSTRUCTORS
CombCallVisitor() {} CombCallVisitor() {
m_find = false;
}
virtual ~CombCallVisitor() {} virtual ~CombCallVisitor() {}
void main(AstNetlist* nodep) { void main(AstNetlist* nodep) {
nodep->accept(*this); nodep->accept(*this);

View File

@ -821,7 +821,9 @@ private:
AstNodeAssign* asn2ap=nodep->cloneType(lc2p, sel2p)->castNodeAssign(); AstNodeAssign* asn2ap=nodep->cloneType(lc2p, sel2p)->castNodeAssign();
asn1ap->width(msb1-lsb1+1,msb1-lsb1+1); asn1ap->width(msb1-lsb1+1,msb1-lsb1+1);
asn2ap->width(msb2-lsb2+1,msb2-lsb2+1); asn2ap->width(msb2-lsb2+1,msb2-lsb2+1);
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn1ap); newp = newp->addNext(asn1ap);
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn2ap); newp = newp->addNext(asn2ap);
} else { } else {
if (!m_modp) nodep->v3fatalSrc("Not under module"); if (!m_modp) nodep->v3fatalSrc("Not under module");
@ -852,12 +854,16 @@ private:
asn2ap->width(msb2-lsb2+1,msb2-lsb2+1); asn2ap->width(msb2-lsb2+1,msb2-lsb2+1);
asn2bp->width(msb2-lsb2+1,msb2-lsb2+1); asn2bp->width(msb2-lsb2+1,msb2-lsb2+1);
// This order matters // This order matters
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn1ap); newp = newp->addNext(asn1ap);
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn2ap); newp = newp->addNext(asn2ap);
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn1bp); newp = newp->addNext(asn1bp);
// cppcheck-suppress nullPointer // addNext deals with it
newp = newp->addNext(asn2bp); newp = newp->addNext(asn2bp);
} }
if (debug()>=9) newp->dumpTreeAndNext(cout," _new: "); if (debug()>=9 && newp) newp->dumpTreeAndNext(cout," _new: ");
nodep->addNextHere(newp); nodep->addNextHere(newp);
// Cleanup // Cleanup
nodep->unlinkFrBack()->deleteTree(); nodep=NULL; nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
@ -1534,7 +1540,7 @@ private:
UINFO(9," DispConst: "<<fmt<<" -> "<<out<<" for "<<argp<<endl); UINFO(9," DispConst: "<<fmt<<" -> "<<out<<" for "<<argp<<endl);
{ // fmt = out w/ replace % with %% as it must be literal. { // fmt = out w/ replace % with %% as it must be literal.
fmt = ""; fmt = "";
for (string::iterator pos = out.begin(); pos != out.end(); pos++) { for (string::iterator pos = out.begin(); pos != out.end(); ++pos) {
if (*pos == '%') fmt += '%'; if (*pos == '%') fmt += '%';
fmt += *pos; fmt += *pos;
} }

View File

@ -55,9 +55,9 @@ public:
} }
// ACCESSORS // ACCESSORS
int splitFilenum() { return m_splitFilenum; } int splitFilenum() const { return m_splitFilenum; }
int splitFilenumInc() { m_splitSize = 0; return ++m_splitFilenum; } int splitFilenumInc() { m_splitSize = 0; return ++m_splitFilenum; }
int splitSize() { return m_splitSize; } int splitSize() const { return m_splitSize; }
void splitSizeInc(AstNode* nodep) { m_splitSize += EmitCBaseCounterVisitor(nodep).count(); } void splitSizeInc(AstNode* nodep) { m_splitSize += EmitCBaseCounterVisitor(nodep).count(); }
bool splitNeeded() { return (splitSize() && v3Global.opt.outputSplit() > 1 bool splitNeeded() { return (splitSize() && v3Global.opt.outputSplit() > 1
&& v3Global.opt.outputSplit() < splitSize()); } && v3Global.opt.outputSplit() < splitSize()); }
@ -830,6 +830,8 @@ class EmitCImp : EmitCStmts {
public: public:
EmitCImp() { EmitCImp() {
m_modp = NULL; m_modp = NULL;
m_slow = false;
m_fast = false;
} }
virtual ~EmitCImp() {} virtual ~EmitCImp() {}
void main(AstNodeModule* modp, bool slow, bool fast); void main(AstNodeModule* modp, bool slow, bool fast);
@ -1424,6 +1426,7 @@ void EmitCImp::emitStaticDecl(AstNodeModule* modp) {
// Need implementation here. Be careful of alignment code; needs to be uniquified // Need implementation here. Be careful of alignment code; needs to be uniquified
// with module name to avoid multiple symbols. // with module name to avoid multiple symbols.
//emitVarList(modp->stmtsp(), EVL_ALL, modp->name()); //emitVarList(modp->stmtsp(), EVL_ALL, modp->name());
puts(""); // NOP for cppcheck, otherwise const function
} }
void EmitCImp::emitTextSection(AstType type) { void EmitCImp::emitTextSection(AstType type) {

View File

@ -526,8 +526,8 @@ void EmitCSyms::emitDpiHdr() {
puts("#endif\n"); puts("#endif\n");
puts("\n"); puts("\n");
bool firstExp = false; int firstExp = 0;
bool firstImp = false; int firstImp = 0;
for (vector<AstCFunc*>::iterator it = m_dpis.begin(); it != m_dpis.end(); ++it) { for (vector<AstCFunc*>::iterator it = m_dpis.begin(); it != m_dpis.end(); ++it) {
AstCFunc* nodep = *it; AstCFunc* nodep = *it;
if (nodep->dpiExportWrapper()) { if (nodep->dpiExportWrapper()) {

View File

@ -370,7 +370,7 @@ void V3Error::suppressThisWarning() {
} }
void V3Error::v3errorEnd (ostringstream& sstr) { void V3Error::v3errorEnd (ostringstream& sstr) {
#ifdef __COVERITY__ #if defined(__COVERITY__) || defined(__cppcheck__)
if (s_errorCode==V3ErrorCode::EC_FATAL) __coverity_panic__(x); if (s_errorCode==V3ErrorCode::EC_FATAL) __coverity_panic__(x);
#endif #endif
if (!s_errorSuppressed if (!s_errorSuppressed

View File

@ -90,7 +90,7 @@ public:
// ***Add new elements below also*** // ***Add new elements below also***
}; };
enum en m_e; enum en m_e;
inline V3ErrorCode () {} inline V3ErrorCode () : m_e(EC_MIN) {}
inline V3ErrorCode (en _e) : m_e(_e) {} inline V3ErrorCode (en _e) : m_e(_e) {}
V3ErrorCode (const char* msgp); // Matching code or ERROR V3ErrorCode (const char* msgp); // Matching code or ERROR
explicit inline V3ErrorCode (int _e) : m_e(static_cast<en>(_e)) {} explicit inline V3ErrorCode (int _e) : m_e(static_cast<en>(_e)) {}
@ -315,7 +315,7 @@ public:
// OPERATORS // OPERATORS
void v3errorEnd(ostringstream& str); void v3errorEnd(ostringstream& str);
inline bool operator==(FileLine rhs) { inline bool operator==(FileLine rhs) const {
return (m_lineno==rhs.m_lineno && m_filename==rhs.m_filename && m_warnOn==rhs.m_warnOn); return (m_lineno==rhs.m_lineno && m_filename==rhs.m_filename && m_warnOn==rhs.m_warnOn);
} }
}; };

View File

@ -327,6 +327,7 @@ private:
#endif #endif
} }
// cppcheck-suppress functionConst
void checkFilter(bool hang) { void checkFilter(bool hang) {
#ifdef INFILTER_PIPE #ifdef INFILTER_PIPE
if (!m_pidExited && waitpid(m_pid, &m_pidStatus, hang?0:WNOHANG)) { if (!m_pidExited && waitpid(m_pid, &m_pidStatus, hang?0:WNOHANG)) {
@ -355,6 +356,7 @@ private:
|| errno == EWOULDBLOCK || errno == EWOULDBLOCK
#endif #endif
) { ) {
// cppcheck-suppress obsoleteFunctionsusleep
checkFilter(false); usleep(1000); continue; checkFilter(false); usleep(1000); continue;
} else { m_readEof = true; break; } } else { m_readEof = true; break; }
} }
@ -390,6 +392,7 @@ private:
|| errno == EWOULDBLOCK || errno == EWOULDBLOCK
#endif #endif
) { ) {
// cppcheck-suppress obsoleteFunctionsusleep
checkFilter(false); usleep(1000); continue; checkFilter(false); usleep(1000); continue;
} }
else break; else break;

View File

@ -326,6 +326,7 @@ public:
class V3GraphTestImport : public V3GraphTest { class V3GraphTestImport : public V3GraphTest {
// cppcheck-suppress functionConst
void dotImport(); void dotImport();
public: public:

View File

@ -293,6 +293,7 @@ private:
// LIFE MAP // LIFE MAP
// For each basic block, we'll make a new map of what variables that if/else is changing // For each basic block, we'll make a new map of what variables that if/else is changing
typedef std::map<AstVarScope*, LifeVarEntry> LifeMap; typedef std::map<AstVarScope*, LifeVarEntry> LifeMap;
// cppcheck-suppress memleak // cppcheck bug - it is deleted
LifeBlock* m_lifep; // Current active lifetime map for current scope LifeBlock* m_lifep; // Current active lifetime map for current scope
// METHODS // METHODS
@ -455,6 +456,8 @@ public:
m_sideEffect = false; m_sideEffect = false;
m_noopt = false; m_noopt = false;
{ {
// Cpp check bug, it is deleted
// cppcheck-suppress leak
m_lifep = new LifeBlock (NULL, m_statep); m_lifep = new LifeBlock (NULL, m_statep);
nodep->accept(*this); nodep->accept(*this);
delete m_lifep; m_lifep=NULL; delete m_lifep; m_lifep=NULL;

View File

@ -60,7 +60,7 @@ private:
T m_nextp; // Pointer to next element, NULL=end T m_nextp; // Pointer to next element, NULL=end
T m_prevp; // Pointer to previous element, NULL=beginning T m_prevp; // Pointer to previous element, NULL=beginning
friend class V3List<T>; friend class V3List<T>;
static V3ListEnt* baseToListEnt(void* newbasep, uint32_t offset) { static V3ListEnt* baseToListEnt(void* newbasep, size_t offset) {
// "this" must be a element inside of *basep // "this" must be a element inside of *basep
// Use that to determine a structure offset, then apply to the new base // Use that to determine a structure offset, then apply to the new base
// to get our new pointer information // to get our new pointer information
@ -80,7 +80,8 @@ public:
// METHODS // METHODS
void pushBack (V3List<T>& listr, T newp) { void pushBack (V3List<T>& listr, T newp) {
// "this" must be a element inside of *newp // "this" must be a element inside of *newp
uint32_t offset = (vluint8_t*)(this) - (vluint8_t*)(newp); // cppcheck-suppress thisSubtraction
size_t offset = (vluint8_t*)(this) - (vluint8_t*)(newp);
m_nextp = NULL; m_nextp = NULL;
if (!listr.m_headp) listr.m_headp = newp; if (!listr.m_headp) listr.m_headp = newp;
m_prevp = listr.m_tailp; m_prevp = listr.m_tailp;
@ -89,7 +90,8 @@ public:
} }
void pushFront (V3List<T>& listr, T newp) { void pushFront (V3List<T>& listr, T newp) {
// "this" must be a element inside of *newp // "this" must be a element inside of *newp
uint32_t offset = (vluint8_t*)(this) - (vluint8_t*)(newp); // cppcheck-suppress thisSubtraction
size_t offset = (vluint8_t*)(this) - (vluint8_t*)(newp);
m_nextp = listr.m_headp; m_nextp = listr.m_headp;
if (m_nextp) baseToListEnt(m_nextp,offset)->m_prevp = newp; if (m_nextp) baseToListEnt(m_nextp,offset)->m_prevp = newp;
listr.m_headp = newp; listr.m_headp = newp;
@ -99,7 +101,8 @@ public:
// Unlink from side // Unlink from side
void unlink (V3List<T>& listr, T oldp) { void unlink (V3List<T>& listr, T oldp) {
// "this" must be a element inside of *oldp // "this" must be a element inside of *oldp
uint32_t offset = (vluint8_t*)(this) - (vluint8_t*)(oldp); // cppcheck-suppress thisSubtraction
size_t offset = (vluint8_t*)(this) - (vluint8_t*)(oldp);
if (m_nextp) baseToListEnt(m_nextp,offset)->m_prevp = m_prevp; if (m_nextp) baseToListEnt(m_nextp,offset)->m_prevp = m_prevp;
else listr.m_tailp = m_prevp; else listr.m_tailp = m_prevp;
if (m_prevp) baseToListEnt(m_prevp,offset)->m_nextp = m_nextp; if (m_prevp) baseToListEnt(m_prevp,offset)->m_nextp = m_nextp;

View File

@ -33,28 +33,10 @@
// Read class functions // Read class functions
// CREATION // CREATION
void V3Number::width(int width, bool sized) {
// Set width. Only set m_width here, as we need to tweak vector size
if (width) { m_sized = sized; m_width=width; }
else { m_sized = false; m_width=1; }
if (m_value.size() < (unsigned)(words()+1)) {
m_value.resize(words()+1);
m_valueX.resize(words()+1);
}
}
void V3Number::init (FileLine* fileline, int swidth) {
m_fileline = fileline;
m_signed = false;
m_double = false;
m_autoExtend = false;
m_fromString = false;
width(swidth);
for (int i=0; i<words(); i++) m_value[i]=m_valueX[i] = 0;
}
V3Number::V3Number(VerilogString, FileLine* fileline, const string& str) { V3Number::V3Number(VerilogString, FileLine* fileline, const string& str) {
// Create a number using a verilog string as the value, thus 8 bits per character. // Create a number using a verilog string as the value, thus 8 bits per character.
// cppcheck bug - doesn't see init() resets these
// cppcheck: Member variable 'm_sized/m_width' is not initialized in the constructor
init(fileline, str.length()*8); init(fileline, str.length()*8);
m_fromString = true; m_fromString = true;
for (unsigned pos=0; pos<str.length(); ++pos) { for (unsigned pos=0; pos<str.length(); ++pos) {

View File

@ -42,7 +42,6 @@ class V3Number {
vector<uint32_t> m_value; // The Value, with bit 0 being in bit 0 of this vector (unless X/Z) vector<uint32_t> m_value; // The Value, with bit 0 being in bit 0 of this vector (unless X/Z)
vector<uint32_t> m_valueX; // Each bit is true if it's X or Z, 10=z, 11=x vector<uint32_t> m_valueX; // Each bit is true if it's X or Z, 10=z, 11=x
// METHODS // METHODS
void init(FileLine* fileline, int width);
V3Number& setSingleBits(char value); V3Number& setSingleBits(char value);
void opCleanThis(); void opCleanThis();
public: public:
@ -118,6 +117,27 @@ public:
V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number. V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number.
V3Number(VerilogString, FileLine* fileline, const string& vvalue); V3Number(VerilogString, FileLine* fileline, const string& vvalue);
private:
void init(FileLine* fileline, int swidth) {
m_fileline = fileline;
m_signed = false;
m_double = false;
m_autoExtend = false;
m_fromString = false;
width(swidth);
for (int i=0; i<words(); i++) m_value[i]=m_valueX[i] = 0;
}
public:
void width(int width, bool sized=true) {
// Set width. Only set m_width here, as we need to tweak vector size
if (width) { m_sized = sized; m_width=width; }
else { m_sized = false; m_width=1; }
if (VL_UNLIKELY(m_value.size() < (unsigned)(words()+1))) {
m_value.resize(words()+1);
m_valueX.resize(words()+1);
}
}
// SETTERS // SETTERS
V3Number& setAllBitsX(); V3Number& setAllBitsX();
V3Number& setAllBitsZ(); V3Number& setAllBitsZ();
@ -147,7 +167,6 @@ public:
bool isEqAllOnes(int optwidth=0) const; bool isEqAllOnes(int optwidth=0) const;
bool isCaseEq(const V3Number& rhsp) const; // operator== bool isCaseEq(const V3Number& rhsp) const; // operator==
bool isLt(const V3Number& rhsp) const; // operator< bool isLt(const V3Number& rhsp) const; // operator<
void width(int width, bool sized=true);
void isSigned(bool ssigned) { m_signed=ssigned; } void isSigned(bool ssigned) { m_signed=ssigned; }
bool isUnknown() const; bool isUnknown() const;
uint32_t toUInt() const; uint32_t toUInt() const;

View File

@ -528,6 +528,11 @@ string V3Options::version() {
return ver; return ver;
} }
void V3Options::throwSigsegv() {
// cppcheck-suppress nullPointer
char* zp=NULL; *zp=0;
}
//###################################################################### //######################################################################
// V3 Options utilities // V3 Options utilities
@ -643,7 +648,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if ( onoff (sw, "-covsp", flag/*ref*/) ) { } // TBD else if ( onoff (sw, "-covsp", flag/*ref*/) ) { } // TBD
else if ( !strcmp (sw, "-debug-abort") ) { abort(); } // Undocumented, see also --debug-sigsegv else if ( !strcmp (sw, "-debug-abort") ) { abort(); } // Undocumented, see also --debug-sigsegv
else if ( onoff (sw, "-debug-check", flag/*ref*/) ){ m_debugCheck = flag; } else if ( onoff (sw, "-debug-check", flag/*ref*/) ){ m_debugCheck = flag; }
else if ( !strcmp (sw, "-debug-sigsegv") ) { char* zp=NULL; *zp=0; } // Undocumented, see also --debug-abort else if ( !strcmp (sw, "-debug-sigsegv") ) { throwSigsegv(); } // Undocumented, see also --debug-abort
else if ( !strcmp (sw, "-debug-fatalsrc") ) { v3fatalSrc("--debug-fatal-src"); } // Undocumented, see also --debug-abort else if ( !strcmp (sw, "-debug-fatalsrc") ) { v3fatalSrc("--debug-fatal-src"); } // Undocumented, see also --debug-abort
else if ( onoff (sw, "-dump-tree", flag/*ref*/) ) { m_dumpTree = flag; } else if ( onoff (sw, "-dump-tree", flag/*ref*/) ) { m_dumpTree = flag; }
else if ( onoff (sw, "-exe", flag/*ref*/) ) { m_exe = flag; } else if ( onoff (sw, "-exe", flag/*ref*/) ) { m_exe = flag; }
@ -973,6 +978,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
break; // Ignore to EOL break; // Ignore to EOL
} else if (*pos=='/' && *(pos+1)=='*') { } else if (*pos=='/' && *(pos+1)=='*') {
inCmt = true; inCmt = true;
// cppcheck-suppress StlMissingComparison
++pos; ++pos;
} else { } else {
oline += *pos; oline += *pos;

View File

@ -347,6 +347,9 @@ class V3Options {
string filePath (FileLine* fl, const string& modname, const string& errmsg); string filePath (FileLine* fl, const string& modname, const string& errmsg);
static bool fileStatDir (const string& filename); static bool fileStatDir (const string& filename);
static bool fileStatNormal (const string& filename); static bool fileStatNormal (const string& filename);
// METHODS (other OS)
static void throwSigsegv();
}; };
//###################################################################### //######################################################################

View File

@ -148,7 +148,7 @@ private:
public: public:
OrderMoveDomScope(OrderLoopId inLoop, AstSenTree* domainp, AstScope* scopep) OrderMoveDomScope(OrderLoopId inLoop, AstSenTree* domainp, AstScope* scopep)
: m_onReadyList(false), m_domainp(domainp), m_inLoop(inLoop) {} : m_onReadyList(false), m_domainp(domainp), m_scopep(scopep), m_inLoop(inLoop) {}
OrderMoveDomScope* readyDomScopeNextp() const { return m_readyDomScopeE.nextp(); } OrderMoveDomScope* readyDomScopeNextp() const { return m_readyDomScopeE.nextp(); }
OrderLoopId inLoop() const { return m_inLoop; } OrderLoopId inLoop() const { return m_inLoop; }
AstSenTree* domainp() const { return m_domainp; } AstSenTree* domainp() const { return m_domainp; }
@ -391,8 +391,8 @@ private:
void nodeMarkCircular(OrderVarVertex* vertexp, OrderEdge* edgep) { void nodeMarkCircular(OrderVarVertex* vertexp, OrderEdge* edgep) {
AstVarScope* nodep = vertexp->varScp(); AstVarScope* nodep = vertexp->varScp();
nodep->circular(true); nodep->circular(true);
m_statCut[vertexp->type()]++; ++m_statCut[vertexp->type()];
if (edgep) m_statCut[edgep->type()]++; if (edgep) ++m_statCut[edgep->type()];
if (vertexp->isClock()) { if (vertexp->isClock()) {
// Seems obvious; no warning yet // Seems obvious; no warning yet
//nodep->v3warn(GENCLK,"Signal unoptimizable: Generated clock: "<<nodep->prettyName()); //nodep->v3warn(GENCLK,"Signal unoptimizable: Generated clock: "<<nodep->prettyName());
@ -715,6 +715,9 @@ public:
m_settleDomainp = NULL; m_settleDomainp = NULL;
m_settleVxp = NULL; m_settleVxp = NULL;
m_inputsVxp = NULL; m_inputsVxp = NULL;
m_activeSenVxp = NULL;
m_logicVxp = NULL;
m_pomNewFuncp = NULL;
m_loopIdMax = LOOPID_FIRST; m_loopIdMax = LOOPID_FIRST;
m_pomNewStmts = 0; m_pomNewStmts = 0;
if (debug()) m_graph.debug(5); // 3 is default if global debug; we want acyc debugging if (debug()) m_graph.debug(5); // 3 is default if global debug; we want acyc debugging

View File

@ -105,7 +105,7 @@ struct OrderVEdgeType {
return names[m_e]; return names[m_e];
} }
enum en m_e; enum en m_e;
inline OrderVEdgeType () {} inline OrderVEdgeType () : m_e(VERTEX_UNKNOWN) {}
inline OrderVEdgeType (en _e) : m_e(_e) {} inline OrderVEdgeType (en _e) : m_e(_e) {}
explicit inline OrderVEdgeType (int _e) : m_e(static_cast<en>(_e)) {} explicit inline OrderVEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; } operator en () const { return m_e; }

View File

@ -257,7 +257,7 @@ public:
double parseDouble(const char* text, size_t length); double parseDouble(const char* text, size_t length);
void pushBeginKeywords(int state) { m_inBeginKwd++; m_lastVerilogState=state; } void pushBeginKeywords(int state) { m_inBeginKwd++; m_lastVerilogState=state; }
bool popBeginKeywords() { if (m_inBeginKwd) { m_inBeginKwd--; return true; } else return false; } bool popBeginKeywords() { if (m_inBeginKwd) { m_inBeginKwd--; return true; } else return false; }
int lastVerilogState() { return m_lastVerilogState; } int lastVerilogState() const { return m_lastVerilogState; }
static const char* tokenName(int tok); static const char* tokenName(int tok);
void ppPushText(const string& text) { m_ppBuffers.push_back(text); } void ppPushText(const string& text) { m_ppBuffers.push_back(text); }
@ -291,12 +291,12 @@ public:
} }
// Return next token, for bison, since bison isn't class based, use a global THIS // Return next token, for bison, since bison isn't class based, use a global THIS
FileLine* fileline() { return m_fileline; } FileLine* fileline() const { return m_fileline; }
AstNetlist* rootp() { return m_rootp; } AstNetlist* rootp() const { return m_rootp; }
FileLine* copyOrSameFileLine() { return fileline()->copyOrSameFileLine(); } FileLine* copyOrSameFileLine() { return fileline()->copyOrSameFileLine(); }
bool inCellDefine() { return m_inCellDefine; } bool inCellDefine() const { return m_inCellDefine; }
void inCellDefine(bool flag) { m_inCellDefine = flag; } void inCellDefine(bool flag) { m_inCellDefine = flag; }
bool inLibrary() { return m_inLibrary; } bool inLibrary() const { return m_inLibrary; }
// Interactions with parser // Interactions with parser
int bisonParse(); int bisonParse();
@ -307,7 +307,7 @@ public:
void stateExitPsl(); // Parser -> lexer communication void stateExitPsl(); // Parser -> lexer communication
void statePushVlg(); // Parser -> lexer communication void statePushVlg(); // Parser -> lexer communication
void statePop(); // Parser -> lexer communication void statePop(); // Parser -> lexer communication
int stateVerilogRecent(); // Parser -> lexer communication static int stateVerilogRecent(); // Parser -> lexer communication
size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf,max_size); } size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf,max_size); }
//==== Symbol tables //==== Symbol tables
@ -317,6 +317,7 @@ public:
// CREATORS // CREATORS
V3ParseImp(AstNetlist* rootp, V3InFilter* filterp) V3ParseImp(AstNetlist* rootp, V3InFilter* filterp)
: m_sym(rootp), m_filterp(filterp) { : m_sym(rootp), m_filterp(filterp) {
m_fileline = NULL;
m_rootp = rootp; m_lexerp = NULL; m_rootp = rootp; m_lexerp = NULL;
m_inCellDefine = false; m_inCellDefine = false;
m_inLibrary = false; m_inLibrary = false;

View File

@ -203,7 +203,7 @@ class V3PreLex {
/// Called by V3PreProc.cpp to get data from lexer /// Called by V3PreProc.cpp to get data from lexer
YY_BUFFER_STATE currentBuffer(); YY_BUFFER_STATE currentBuffer();
int lex(); int lex();
int currentStartState(); int currentStartState() const;
void dumpSummary(); void dumpSummary();
void dumpStack(); void dumpStack();
void unused(); void unused();

View File

@ -488,7 +488,7 @@ YY_BUFFER_STATE V3PreLex::currentBuffer() {
return YY_CURRENT_BUFFER; return YY_CURRENT_BUFFER;
} }
int V3PreLex::currentStartState() { int V3PreLex::currentStartState() const {
return YY_START; return YY_START;
} }

View File

@ -251,6 +251,10 @@ public:
m_finAtBol = true; m_finAtBol = true;
m_defDepth = 0; m_defDepth = 0;
m_defPutJoin = false; m_defPutJoin = false;
m_finToken = 0;
m_finFilelinep = NULL;
m_lexp = NULL;
m_preprocp = NULL;
} }
void configure(FileLine* filelinep) { void configure(FileLine* filelinep) {
// configure() separate from constructor to avoid calling abstract functions // configure() separate from constructor to avoid calling abstract functions

View File

@ -71,19 +71,19 @@ class TraceActivityVertex : public V3GraphVertex {
bool m_activityCodeValid; bool m_activityCodeValid;
bool m_slow; // If always slow, we can use the same code bool m_slow; // If always slow, we can use the same code
public: public:
enum { ACTIVITY_NEVER =((1UL<<31) - 1) };
enum { ACTIVITY_ALWAYS=((1UL<<31) - 2) };
enum { ACTIVITY_SLOW=0 };
TraceActivityVertex(V3Graph* graphp, AstNode* nodep, bool slow) TraceActivityVertex(V3Graph* graphp, AstNode* nodep, bool slow)
: V3GraphVertex(graphp), m_insertp(nodep) { : V3GraphVertex(graphp), m_insertp(nodep) {
m_activityCode = 0; m_activityCode = 0;
m_activityCodeValid = false; m_activityCodeValid = false;
m_slow = slow; m_slow = slow;
} }
enum { ACTIVITY_NEVER =((1UL<<31) - 1) };
enum { ACTIVITY_ALWAYS=((1UL<<31) - 2) };
enum { ACTIVITY_SLOW=0 };
class ActivityAlways {};
TraceActivityVertex(V3Graph* graphp, vlsint32_t code) TraceActivityVertex(V3Graph* graphp, vlsint32_t code)
: V3GraphVertex(graphp) { : V3GraphVertex(graphp), m_insertp(NULL) {
activityCode(code); m_activityCode = code;
m_activityCodeValid = true;
m_slow = false; m_slow = false;
} }
virtual ~TraceActivityVertex() {} virtual ~TraceActivityVertex() {}

View File

@ -103,6 +103,7 @@ private:
} else { } else {
basep->v3fatalSrc("Strange base function type"); basep->v3fatalSrc("Strange base function type");
} }
// cppcheck-suppress nullPointer // above fatal prevents it
AstCCall* callp = new AstCCall(funcp->fileline(), funcp); AstCCall* callp = new AstCCall(funcp->fileline(), funcp);
callp->argTypes("vlSymsp, vcdp, code"); callp->argTypes("vlSymsp, vcdp, code");
basep->addStmtsp(callp); basep->addStmtsp(callp);

View File

@ -76,8 +76,8 @@ public:
private: private:
// METHODS // METHODS
inline bool bitNumOk(int bit) const { return (bit*FLAGS_PER_BIT < (int)m_flags.size()); } inline bool bitNumOk(int bit) const { return (bit*FLAGS_PER_BIT < (int)m_flags.size()); }
inline bool usedFlag(int bit) { return m_usedWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_USED]; } inline bool usedFlag(int bit) const { return m_usedWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_USED]; }
inline bool drivenFlag(int bit) { return m_drivenWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_DRIVEN]; } inline bool drivenFlag(int bit) const { return m_drivenWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_DRIVEN]; }
enum BitNamesWhich { BN_UNUSED, BN_UNDRIVEN, BN_BOTH }; enum BitNamesWhich { BN_UNUSED, BN_UNDRIVEN, BN_BOTH };
string bitNames(BitNamesWhich which) { string bitNames(BitNamesWhich which) {
string bits=""; string bits="";

View File

@ -241,14 +241,17 @@ private:
} }
if (precondsp) { if (precondsp) {
precondsp->unlinkFrBackWithNext(); precondsp->unlinkFrBackWithNext();
// cppcheck-suppress nullPointer // addNextNull deals with it
stmtsp = stmtsp->addNextNull(precondsp); stmtsp = stmtsp->addNextNull(precondsp);
} }
if (bodysp) { if (bodysp) {
bodysp->unlinkFrBackWithNext(); bodysp->unlinkFrBackWithNext();
// cppcheck-suppress nullPointer // addNextNull deals with it
stmtsp = stmtsp->addNextNull(bodysp); // Maybe null if no body stmtsp = stmtsp->addNextNull(bodysp); // Maybe null if no body
} }
if (incp && !nodep->castGenFor()) { // Generates don't need to increment loop index if (incp && !nodep->castGenFor()) { // Generates don't need to increment loop index
incp->unlinkFrBackWithNext(); incp->unlinkFrBackWithNext();
// cppcheck-suppress nullPointer // addNextNull deals with it
stmtsp = stmtsp->addNextNull(incp); // Maybe null if no body stmtsp = stmtsp->addNextNull(incp); // Maybe null if no body
} }
// Mark variable to disable some later warnings // Mark variable to disable some later warnings

View File

@ -687,7 +687,7 @@ private:
bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit(); bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit();
if (implicitParam) { if (implicitParam) {
AstNumeric rs = AstNumeric::UNSIGNED; AstNumeric rs = AstNumeric::UNSIGNED;
int width=0; int mwidth=0; int width=0;
if (nodep->valuep()) { if (nodep->valuep()) {
nodep->valuep()->iterateAndNext(*this,WidthVP(width,0,PRELIM).p()); nodep->valuep()->iterateAndNext(*this,WidthVP(width,0,PRELIM).p());
// Although nodep will get a different width for parameters just below, // Although nodep will get a different width for parameters just below,
@ -697,11 +697,10 @@ private:
rs = nodep->numeric(); rs = nodep->numeric();
if (!rs.isDouble()) { if (!rs.isDouble()) {
if (nodep->valuep()->widthSized()) { if (nodep->valuep()->widthSized()) {
width = mwidth = nodep->valuep()->width(); width = nodep->valuep()->width();
} else { } else {
if (nodep->valuep()->width()>32) nodep->valuep()->v3warn(WIDTH,"Assigning >32 bit to unranged parameter (defaults to 32 bits)"); if (nodep->valuep()->width()>32) nodep->valuep()->v3warn(WIDTH,"Assigning >32 bit to unranged parameter (defaults to 32 bits)");
width = 32; width = 32;
mwidth = nodep->valuep()->widthMin();
} }
} }
} }

View File

@ -25,7 +25,7 @@
//********************************************************************** //**********************************************************************
//**** Version and host name //**** Version and host name
#define DTVERSION "Verilator 3.820 2011/07/28" #define DTVERSION "Verilator 3.820 devel"
//********************************************************************** //**********************************************************************
//**** Functions //**** Functions