diff --git a/Makefile.in b/Makefile.in index 205ff22cc..a18c34070 100644 --- a/Makefile.in +++ b/Makefile.in @@ -371,6 +371,15 @@ endif # VERILATOR_AUTHOR_SITE 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 install-msg: diff --git a/include/verilated.cpp b/include/verilated.cpp index bf911fa4d..457159cef 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -1079,6 +1079,7 @@ VerilatedScope::VerilatedScope() { m_callbacksp = NULL; m_namep = NULL; m_funcnumMax = 0; + m_symsp = NULL; m_varsp = NULL; } diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 194ba3e62..431888501 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -110,6 +110,7 @@ private: void dumpHeader(); void dumpPrep (vluint64_t timeui); void dumpFull (vluint64_t timeui); + // cppcheck-suppress functionConst void dumpDone (); inline void printCode (vluint32_t code) { 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)); *m_writep++ = ((char)((code)%94+33)); } - string stringCode (vluint32_t code) { + static string stringCode (vluint32_t code) { string out; if (code>=(94*94*94)) out += ((char)((code/94/94/94)%94+33)); if (code>=(94*94)) out += ((char)((code/94/94)%94+33)); @@ -141,6 +142,8 @@ public: m_evcd = false; m_scopeEscape = '.'; // Backward compatibility m_wroteBytes = 0; + m_fd = 0; + m_fullDump = true; } ~VerilatedVcd(); diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 211295851..80f8bd3c6 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -98,7 +98,9 @@ class VerilatedVpioCb : public VerilatedVpio { s_vpi_value m_value; QData m_time; 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; } virtual ~VerilatedVpioCb() {} diff --git a/src/V3Active.cpp b/src/V3Active.cpp index b6a60398e..9d190d507 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -148,7 +148,11 @@ public: } public: // CONSTUCTORS - ActiveNamer() {} + ActiveNamer() { + m_scopep = NULL; + m_iActivep = NULL; + m_cActivep = NULL; + } virtual ~ActiveNamer() {} void main(AstScope* nodep) { nodep->accept(*this); diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 09450f6e2..2720058fd 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -430,7 +430,7 @@ void AstNode::replaceWith(AstNode* newp) { repHandle.relink(newp); } -void AstNRelinker::dump(ostream& str) { +void AstNRelinker::dump(ostream& str) const { str<<" BK="<<(uint32_t*)m_backp; str<<" ITER="<<(uint32_t*)m_iterpp; 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="<(_e)) {} operator en () const { return m_e; } @@ -238,6 +240,7 @@ public: class AstBasicDTypeKwd { public: enum en { + UNKNOWN, BIT, BYTE, CHANDLE, INT, INTEGER, LOGIC, LONGINT, DOUBLE, SHORTINT, FLOAT, TIME, // Closer to a class type, but limited usage @@ -250,6 +253,7 @@ public: enum en m_e; const char* ascii() const { static const char* names[] = { + "%E-unk", "bit", "byte", "chandle", "int", "integer", "logic", "longint", "real", "shortint", "shortreal", "time", "string", @@ -260,6 +264,7 @@ public: }; const char* dpiType() const { static const char* names[] = { + "%E-unk", "unsigned char", "char", "void*", "int", "int", "svLogic", "long long", "double", "short int", "float", "long long", "const char*", @@ -268,7 +273,7 @@ public: }; return names[m_e]; }; - inline AstBasicDTypeKwd () {} + inline AstBasicDTypeKwd () : m_e(UNKNOWN) {} inline AstBasicDTypeKwd (en _e) : m_e(_e) {} explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -351,7 +356,7 @@ public: XTEMP }; enum en m_e; - inline AstVarType () {} + inline AstVarType () : m_e(UNKNOWN) {} inline AstVarType (en _e) : m_e(_e) {} explicit inline AstVarType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -409,7 +414,7 @@ public: CT_CASEZ }; enum en m_e; - inline AstCaseType () {} + inline AstCaseType () : m_e(CT_CASE) {} inline AstCaseType (en _e) : m_e(_e) {} explicit inline AstCaseType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -431,7 +436,7 @@ public: DT_FATAL }; enum en m_e; - inline AstDisplayType () {} + inline AstDisplayType () : m_e(DT_DISPLAY) {} inline AstDisplayType (en _e) : m_e(_e) {} explicit inline AstDisplayType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } @@ -641,7 +646,7 @@ public: AstNRelinker() { m_backp=NULL; m_chg=RELINK_BAD; m_iterpp=NULL;} void relink(AstNode* newp); 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;} @@ -754,6 +759,7 @@ class AstNode { void deleteTreeIter(); void deleteNode(); static void relinkOneLink(AstNode*& pointpr, AstNode* newp); + // cppcheck-suppress functionConst void debugTreeChange(const char* prefix, int lineno, bool next); protected: @@ -945,7 +951,7 @@ public: bool sameTree(AstNode* node2p); // Does tree of this == node2p? void deleteTree(); // Always deletes the next link 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 dumpTreeAndNext(ostream& str=cout, const string& indent=" ", int maxDepth=0); void dumpTreeFile(const string& filename, bool append=false); @@ -1012,6 +1018,7 @@ struct AstNodeTermop : public AstNodeMath { ASTNODE_BASE_FUNCS(NodeTermop) // Know no children, and hot function, so skip iterator for speed // See checkTreeIter also that asserts no children + // cppcheck-suppress functionConst void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { } }; @@ -1274,6 +1281,7 @@ public: void packagep(AstPackage* nodep) { m_packagep=nodep; } // Know no children, and hot function, so skip iterator for speed // See checkTreeIter also that asserts no children + // cppcheck-suppress functionConst void iterateChildren(AstNVisitor& v, AstNUser* vup=NULL) { } }; diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index c703cecc5..928aa5d9a 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -461,10 +461,10 @@ public: virtual V3Hash sameHash() const { return V3Hash(); } virtual bool same(AstNode* samep) const { return true; } 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 start(unsigned start) { m_start = start; } - unsigned start() { return m_start; } + unsigned start() const { return m_start; } // Special operators 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? diff --git a/src/V3ClkGater.cpp b/src/V3ClkGater.cpp index 4d77063b9..f3d499cc6 100644 --- a/src/V3ClkGater.cpp +++ b/src/V3ClkGater.cpp @@ -315,6 +315,7 @@ public: m_exprp = exprp; m_original = original; m_state = STATE_UNKNOWN; + m_cloning = false; if (debug()>=9) nodep->dumpTree(cout," GateBodyIn: "); nodep->bodysp()->iterateAndNext(*this); if (debug()>=9) nodep->dumpTree(cout," GateBodyOut: "); diff --git a/src/V3Combine.cpp b/src/V3Combine.cpp index ba3f34218..1504bd45d 100644 --- a/src/V3Combine.cpp +++ b/src/V3Combine.cpp @@ -146,7 +146,9 @@ private: } public: // CONSTRUCTORS - CombCallVisitor() {} + CombCallVisitor() { + m_find = false; + } virtual ~CombCallVisitor() {} void main(AstNetlist* nodep) { nodep->accept(*this); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index f5e7cd08a..29cc946f4 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -821,7 +821,9 @@ private: AstNodeAssign* asn2ap=nodep->cloneType(lc2p, sel2p)->castNodeAssign(); asn1ap->width(msb1-lsb1+1,msb1-lsb1+1); asn2ap->width(msb2-lsb2+1,msb2-lsb2+1); + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn1ap); + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn2ap); } else { if (!m_modp) nodep->v3fatalSrc("Not under module"); @@ -852,12 +854,16 @@ private: asn2ap->width(msb2-lsb2+1,msb2-lsb2+1); asn2bp->width(msb2-lsb2+1,msb2-lsb2+1); // This order matters + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn1ap); + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn2ap); + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn1bp); + // cppcheck-suppress nullPointer // addNext deals with it newp = newp->addNext(asn2bp); } - if (debug()>=9) newp->dumpTreeAndNext(cout," _new: "); + if (debug()>=9 && newp) newp->dumpTreeAndNext(cout," _new: "); nodep->addNextHere(newp); // Cleanup nodep->unlinkFrBack()->deleteTree(); nodep=NULL; @@ -1534,7 +1540,7 @@ private: UINFO(9," DispConst: "< "< 1 && v3Global.opt.outputSplit() < splitSize()); } @@ -830,6 +830,8 @@ class EmitCImp : EmitCStmts { public: EmitCImp() { m_modp = NULL; + m_slow = false; + m_fast = false; } virtual ~EmitCImp() {} 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 // with module name to avoid multiple symbols. //emitVarList(modp->stmtsp(), EVL_ALL, modp->name()); + puts(""); // NOP for cppcheck, otherwise const function } void EmitCImp::emitTextSection(AstType type) { diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 997c0f8f9..4f181eb02 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -526,8 +526,8 @@ void EmitCSyms::emitDpiHdr() { puts("#endif\n"); puts("\n"); - bool firstExp = false; - bool firstImp = false; + int firstExp = 0; + int firstImp = 0; for (vector::iterator it = m_dpis.begin(); it != m_dpis.end(); ++it) { AstCFunc* nodep = *it; if (nodep->dpiExportWrapper()) { diff --git a/src/V3Error.cpp b/src/V3Error.cpp index f8c568c29..d7c4ba40f 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -370,7 +370,7 @@ void V3Error::suppressThisWarning() { } void V3Error::v3errorEnd (ostringstream& sstr) { -#ifdef __COVERITY__ +#if defined(__COVERITY__) || defined(__cppcheck__) if (s_errorCode==V3ErrorCode::EC_FATAL) __coverity_panic__(x); #endif if (!s_errorSuppressed diff --git a/src/V3Error.h b/src/V3Error.h index 848d5a2aa..2d21c0461 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -90,7 +90,7 @@ public: // ***Add new elements below also*** }; enum en m_e; - inline V3ErrorCode () {} + inline V3ErrorCode () : m_e(EC_MIN) {} inline V3ErrorCode (en _e) : m_e(_e) {} V3ErrorCode (const char* msgp); // Matching code or ERROR explicit inline V3ErrorCode (int _e) : m_e(static_cast(_e)) {} @@ -315,7 +315,7 @@ public: // OPERATORS 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); } }; diff --git a/src/V3File.cpp b/src/V3File.cpp index e207bd38c..329772266 100644 --- a/src/V3File.cpp +++ b/src/V3File.cpp @@ -327,6 +327,7 @@ private: #endif } + // cppcheck-suppress functionConst void checkFilter(bool hang) { #ifdef INFILTER_PIPE if (!m_pidExited && waitpid(m_pid, &m_pidStatus, hang?0:WNOHANG)) { @@ -355,6 +356,7 @@ private: || errno == EWOULDBLOCK #endif ) { + // cppcheck-suppress obsoleteFunctionsusleep checkFilter(false); usleep(1000); continue; } else { m_readEof = true; break; } } @@ -390,6 +392,7 @@ private: || errno == EWOULDBLOCK #endif ) { + // cppcheck-suppress obsoleteFunctionsusleep checkFilter(false); usleep(1000); continue; } else break; diff --git a/src/V3GraphTest.cpp b/src/V3GraphTest.cpp index 008233b5b..2bdd45437 100644 --- a/src/V3GraphTest.cpp +++ b/src/V3GraphTest.cpp @@ -326,6 +326,7 @@ public: class V3GraphTestImport : public V3GraphTest { + // cppcheck-suppress functionConst void dotImport(); public: diff --git a/src/V3Life.cpp b/src/V3Life.cpp index 3665dfb90..1fa009a7c 100644 --- a/src/V3Life.cpp +++ b/src/V3Life.cpp @@ -293,6 +293,7 @@ private: // LIFE MAP // For each basic block, we'll make a new map of what variables that if/else is changing typedef std::map LifeMap; + // cppcheck-suppress memleak // cppcheck bug - it is deleted LifeBlock* m_lifep; // Current active lifetime map for current scope // METHODS @@ -455,6 +456,8 @@ public: m_sideEffect = false; m_noopt = false; { + // Cpp check bug, it is deleted + // cppcheck-suppress leak m_lifep = new LifeBlock (NULL, m_statep); nodep->accept(*this); delete m_lifep; m_lifep=NULL; diff --git a/src/V3List.h b/src/V3List.h index 1485ff8d5..96bbc484e 100644 --- a/src/V3List.h +++ b/src/V3List.h @@ -60,7 +60,7 @@ private: T m_nextp; // Pointer to next element, NULL=end T m_prevp; // Pointer to previous element, NULL=beginning friend class V3List; - static V3ListEnt* baseToListEnt(void* newbasep, uint32_t offset) { + static V3ListEnt* baseToListEnt(void* newbasep, size_t offset) { // "this" must be a element inside of *basep // Use that to determine a structure offset, then apply to the new base // to get our new pointer information @@ -80,7 +80,8 @@ public: // METHODS void pushBack (V3List& listr, T 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; if (!listr.m_headp) listr.m_headp = newp; m_prevp = listr.m_tailp; @@ -89,7 +90,8 @@ public: } void pushFront (V3List& listr, T 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; if (m_nextp) baseToListEnt(m_nextp,offset)->m_prevp = newp; listr.m_headp = newp; @@ -99,7 +101,8 @@ public: // Unlink from side void unlink (V3List& listr, T 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; else listr.m_tailp = m_prevp; if (m_prevp) baseToListEnt(m_prevp,offset)->m_nextp = m_nextp; diff --git a/src/V3Number.cpp b/src/V3Number.cpp index bcfde4418..60c8a7d1b 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -33,28 +33,10 @@ // Read class functions // 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 m_value; // The Value, with bit 0 being in bit 0 of this vector (unless X/Z) vector m_valueX; // Each bit is true if it's X or Z, 10=z, 11=x // METHODS - void init(FileLine* fileline, int width); V3Number& setSingleBits(char value); void opCleanThis(); public: @@ -118,6 +117,27 @@ public: V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number. 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; ivarScp(); nodep->circular(true); - m_statCut[vertexp->type()]++; - if (edgep) m_statCut[edgep->type()]++; + ++m_statCut[vertexp->type()]; + if (edgep) ++m_statCut[edgep->type()]; if (vertexp->isClock()) { // Seems obvious; no warning yet //nodep->v3warn(GENCLK,"Signal unoptimizable: Generated clock: "<prettyName()); @@ -715,6 +715,9 @@ public: m_settleDomainp = NULL; m_settleVxp = NULL; m_inputsVxp = NULL; + m_activeSenVxp = NULL; + m_logicVxp = NULL; + m_pomNewFuncp = NULL; m_loopIdMax = LOOPID_FIRST; m_pomNewStmts = 0; if (debug()) m_graph.debug(5); // 3 is default if global debug; we want acyc debugging diff --git a/src/V3OrderGraph.h b/src/V3OrderGraph.h index 3a13ef9b9..b47c69510 100644 --- a/src/V3OrderGraph.h +++ b/src/V3OrderGraph.h @@ -105,7 +105,7 @@ struct OrderVEdgeType { return names[m_e]; } enum en m_e; - inline OrderVEdgeType () {} + inline OrderVEdgeType () : m_e(VERTEX_UNKNOWN) {} inline OrderVEdgeType (en _e) : m_e(_e) {} explicit inline OrderVEdgeType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } diff --git a/src/V3ParseImp.h b/src/V3ParseImp.h index 723a95b66..87ff0f203 100644 --- a/src/V3ParseImp.h +++ b/src/V3ParseImp.h @@ -257,7 +257,7 @@ public: double parseDouble(const char* text, size_t length); void pushBeginKeywords(int state) { m_inBeginKwd++; m_lastVerilogState=state; } 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); 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 - FileLine* fileline() { return m_fileline; } - AstNetlist* rootp() { return m_rootp; } + FileLine* fileline() const { return m_fileline; } + AstNetlist* rootp() const { return m_rootp; } FileLine* copyOrSameFileLine() { return fileline()->copyOrSameFileLine(); } - bool inCellDefine() { return m_inCellDefine; } + bool inCellDefine() const { return m_inCellDefine; } void inCellDefine(bool flag) { m_inCellDefine = flag; } - bool inLibrary() { return m_inLibrary; } + bool inLibrary() const { return m_inLibrary; } // Interactions with parser int bisonParse(); @@ -306,8 +306,8 @@ public: void lexDestroy(); void stateExitPsl(); // Parser -> lexer communication void statePushVlg(); // Parser -> lexer communication - void statePop(); // Parser -> lexer communication - int stateVerilogRecent(); // Parser -> lexer communication + void statePop(); // Parser -> lexer communication + static int stateVerilogRecent(); // Parser -> lexer communication size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf,max_size); } //==== Symbol tables @@ -317,6 +317,7 @@ public: // CREATORS V3ParseImp(AstNetlist* rootp, V3InFilter* filterp) : m_sym(rootp), m_filterp(filterp) { + m_fileline = NULL; m_rootp = rootp; m_lexerp = NULL; m_inCellDefine = false; m_inLibrary = false; diff --git a/src/V3PreLex.h b/src/V3PreLex.h index 557e01246..7afb5860b 100644 --- a/src/V3PreLex.h +++ b/src/V3PreLex.h @@ -203,7 +203,7 @@ class V3PreLex { /// Called by V3PreProc.cpp to get data from lexer YY_BUFFER_STATE currentBuffer(); int lex(); - int currentStartState(); + int currentStartState() const; void dumpSummary(); void dumpStack(); void unused(); diff --git a/src/V3PreLex.l b/src/V3PreLex.l index bbcd419ab..b739f4d93 100644 --- a/src/V3PreLex.l +++ b/src/V3PreLex.l @@ -488,7 +488,7 @@ YY_BUFFER_STATE V3PreLex::currentBuffer() { return YY_CURRENT_BUFFER; } -int V3PreLex::currentStartState() { +int V3PreLex::currentStartState() const { return YY_START; } diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index a07a56414..c6af752ca 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -251,6 +251,10 @@ public: m_finAtBol = true; m_defDepth = 0; m_defPutJoin = false; + m_finToken = 0; + m_finFilelinep = NULL; + m_lexp = NULL; + m_preprocp = NULL; } void configure(FileLine* filelinep) { // configure() separate from constructor to avoid calling abstract functions diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 2fc6e8822..26d891f75 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -71,19 +71,19 @@ class TraceActivityVertex : public V3GraphVertex { bool m_activityCodeValid; bool m_slow; // If always slow, we can use the same code public: + enum { ACTIVITY_NEVER =((1UL<<31) - 1) }; + enum { ACTIVITY_ALWAYS=((1UL<<31) - 2) }; + enum { ACTIVITY_SLOW=0 }; TraceActivityVertex(V3Graph* graphp, AstNode* nodep, bool slow) : V3GraphVertex(graphp), m_insertp(nodep) { m_activityCode = 0; m_activityCodeValid = false; 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) - : V3GraphVertex(graphp) { - activityCode(code); + : V3GraphVertex(graphp), m_insertp(NULL) { + m_activityCode = code; + m_activityCodeValid = true; m_slow = false; } virtual ~TraceActivityVertex() {} diff --git a/src/V3TraceDecl.cpp b/src/V3TraceDecl.cpp index 3c8342dc6..bf9e80540 100644 --- a/src/V3TraceDecl.cpp +++ b/src/V3TraceDecl.cpp @@ -103,6 +103,7 @@ private: } else { basep->v3fatalSrc("Strange base function type"); } + // cppcheck-suppress nullPointer // above fatal prevents it AstCCall* callp = new AstCCall(funcp->fileline(), funcp); callp->argTypes("vlSymsp, vcdp, code"); basep->addStmtsp(callp); diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index 3c1c539ae..fe7c801df 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -76,8 +76,8 @@ public: private: // METHODS 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 drivenFlag(int bit) { return m_drivenWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_DRIVEN]; } + inline bool usedFlag(int bit) const { return m_usedWhole || m_flags[bit*FLAGS_PER_BIT + FLAG_USED]; } + 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 }; string bitNames(BitNamesWhich which) { string bits=""; diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 130eaaf13..f10753ee8 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -241,14 +241,17 @@ private: } if (precondsp) { precondsp->unlinkFrBackWithNext(); + // cppcheck-suppress nullPointer // addNextNull deals with it stmtsp = stmtsp->addNextNull(precondsp); } if (bodysp) { bodysp->unlinkFrBackWithNext(); + // cppcheck-suppress nullPointer // addNextNull deals with it stmtsp = stmtsp->addNextNull(bodysp); // Maybe null if no body } if (incp && !nodep->castGenFor()) { // Generates don't need to increment loop index incp->unlinkFrBackWithNext(); + // cppcheck-suppress nullPointer // addNextNull deals with it stmtsp = stmtsp->addNextNull(incp); // Maybe null if no body } // Mark variable to disable some later warnings diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 51c389b0f..4b0b8cbff 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -687,7 +687,7 @@ private: bool implicitParam = nodep->isParam() && bdtypep && bdtypep->implicit(); if (implicitParam) { AstNumeric rs = AstNumeric::UNSIGNED; - int width=0; int mwidth=0; + int width=0; if (nodep->valuep()) { nodep->valuep()->iterateAndNext(*this,WidthVP(width,0,PRELIM).p()); // Although nodep will get a different width for parameters just below, @@ -697,11 +697,10 @@ private: rs = nodep->numeric(); if (!rs.isDouble()) { if (nodep->valuep()->widthSized()) { - width = mwidth = nodep->valuep()->width(); + width = nodep->valuep()->width(); } else { if (nodep->valuep()->width()>32) nodep->valuep()->v3warn(WIDTH,"Assigning >32 bit to unranged parameter (defaults to 32 bits)"); width = 32; - mwidth = nodep->valuep()->widthMin(); } } } diff --git a/src/config_build.h.in b/src/config_build.h.in index 44844c25b..acd65c060 100644 --- a/src/config_build.h.in +++ b/src/config_build.h.in @@ -25,7 +25,7 @@ //********************************************************************** //**** Version and host name -#define DTVERSION "Verilator 3.820 2011/07/28" +#define DTVERSION "Verilator 3.820 devel" //********************************************************************** //**** Functions