Fix float-conversion warning, bug1229.

This commit is contained in:
Wilson Snyder 2017-10-11 19:01:37 -04:00
parent bc813fddcc
commit de35c90847
9 changed files with 21 additions and 13 deletions

View File

@ -35,6 +35,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix -E duplicating output, bug1226. [Odd Magne Reitan]
**** Fix float-conversion warning, bug1229. [Robert Henry]
* Verilator 3.912 2017-09-23

View File

@ -183,6 +183,7 @@ AC_SUBST(CFG_CXXFLAGS_STD_OLDEST)
# Flags for compiling Verilator internals including parser, and Verilated files
# These turn on extra warnings and are only used with 'configure --enable-ccwarn'
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wextra)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wfloat-conversion)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_WEXTRA,-Wlogical-op)
AC_SUBST(CFG_CXXFLAGS_WEXTRA)

View File

@ -817,7 +817,7 @@ void _VL_VINT_TO_STRING(int obits, char* destoutp, WDataInP sourcep) {
void _VL_STRING_TO_VINT(int obits, void* destp, size_t srclen, const char* srcp) {
// Convert C string to Verilog format
int bytes = VL_BYTES_I(obits);
size_t bytes = VL_BYTES_I(obits);
char* op = reinterpret_cast<char*>(destp);
if (srclen > bytes) srclen = bytes; // Don't overflow destination
size_t i;

View File

@ -354,7 +354,7 @@ void VerilatedVcd::set_time_resolution (const char* unitp) {
double VerilatedVcd::timescaleToDouble (const char* unitp) {
char* endp;
double value = strtod(unitp, &endp);
if (!value) value=1; // On error so we allow just "ns" to return 1e-9.
if (value==0.0 && endp==unitp) value=1; // On error so we allow just "ns" to return 1e-9.
unitp=endp;
while (*unitp && isspace(*unitp)) unitp++;
switch (*unitp) {

View File

@ -121,7 +121,7 @@ uint32_t V3GraphVertex::outHash() const {
ostream& operator<<(ostream& os, V3GraphVertex* vertexp) {
os<<" VERTEX="<<vertexp->name();
if (vertexp->rank()) os<<" r"<<vertexp->rank();
if (vertexp->fanout()) os<<" f"<<vertexp->fanout();
if (vertexp->fanout()!=0.0) os<<" f"<<vertexp->fanout();
if (vertexp->color()) os<<" c"<<vertexp->color();
return os;
}
@ -327,7 +327,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) {
<<"\t[fontsize=8 "
<<"label=\""<<(vertexp->name()!="" ? vertexp->name() : "\\N");
if (vertexp->rank()) *logp<<" r"<<vertexp->rank();
if (vertexp->fanout()) *logp<<" f"<<vertexp->fanout();
if (vertexp->fanout()!=0.0) *logp<<" f"<<vertexp->fanout();
if (vertexp->color()) *logp<<"\\n c"<<vertexp->color();
*logp<<"\"";
*logp<<", color="<<vertexp->dotColor();

View File

@ -1015,7 +1015,8 @@ public:
virtual ~OrderVisitor() {
// Stats
for (int type=0; type<OrderVEdgeType::_ENUM_END; type++) {
if (double count = double(m_statCut[type])) {
double count = double(m_statCut[type]);
if (count != 0.0) {
V3Stats::addStat(string("Order, cut, ")+OrderVEdgeType(type).ascii(), count);
}
}

View File

@ -217,11 +217,12 @@ public:
V3Stats::addStat(m_stage, "Vars, unpacked arrayed", m_statVarArray);
V3Stats::addStat(m_stage, "Vars, clock attribute", m_statVarClock);
V3Stats::addStat(m_stage, "Var space, non-arrays, bytes", m_statVarBytes);
if (m_statVarScpBytes) {
if (m_statVarScpBytes!=0.0) {
V3Stats::addStat(m_stage, "Var space, scoped, bytes", m_statVarScpBytes);
}
for (unsigned i=0; i<m_statVarWidths.size(); i++) {
if (double count = double(m_statVarWidths.at(i))) {
double count = double(m_statVarWidths.at(i));
if (count != 0.0) {
if (v3Global.opt.statsVars()) {
NameMap& nameMapr = m_statVarWidthNames.at(i);
for (NameMap::iterator it=nameMapr.begin(); it!=nameMapr.end(); ++it) {
@ -236,20 +237,23 @@ public:
}
// Node types
for (int type=0; type<AstType::_ENUM_END; type++) {
if (double count = double(m_statTypeCount.at(type))) {
double count = double(m_statTypeCount.at(type));
if (count != 0.0) {
V3Stats::addStat(m_stage, string("Node count, ")+AstType(type).ascii(), count);
}
}
for (int type=0; type<AstType::_ENUM_END; type++) {
for (int type2=0; type2<AstType::_ENUM_END; type2++) {
if (double count = double(m_statAbove[type][type2])) {
double count = double(m_statAbove[type][type2]);
if (count != 0.0) {
V3Stats::addStat(m_stage, string("Node pairs, ")+AstType(type).ascii()+"_"+AstType(type2).ascii(), count);
}
}
}
// Branch pred
for (int type=0; type<AstBranchPred::_ENUM_END; type++) {
if (double count = double(m_statPred[type])) {
double count = double(m_statPred[type]);
if (count != 0.0) {
V3Stats::addStat(m_stage, string("Branch prediction, ")+AstBranchPred(type).ascii(), count);
}
}

View File

@ -74,7 +74,7 @@ public:
cout<<" Covered, Rank, RankPts, Filename"<<endl;
}
void dump(bool bucketsToo) {
if (testrun() || computrons()) {
if (testrun() || computrons()!=0.0) {
cout<<" "<<setw(8)<<setfill('0')<<testrun()
<<", "<<setw(7)<<setfill(' ')<<computrons()<<",";
}

View File

@ -104,7 +104,7 @@ long long dpii_f_longint (long long i) { return ~i; }
void* dpii_f_chandle (void* i) { return i; }
const char* dpii_f_string (const char* i) { return i; }
double dpii_f_real (double i) { return i+1.5; }
float dpii_f_shortreal(float i) { return i+1.5; }
float dpii_f_shortreal(float i) { return i+1.5f; }
void dpii_v_bit (unsigned char i, unsigned char *o) { *o = VL_MASK_I(1) & ~i; }
void dpii_v_int (int i, int *o) { *o = ~i; }
@ -117,7 +117,7 @@ void dpii_v_ulong (unsigned long long i, unsigned long long *o) { *o = ~i; }
void dpii_v_chandle (void* i, void* *o) { *o = i; }
void dpii_v_string (const char* i, const char** o) { *o = i; }
void dpii_v_real (double i, double* o) { *o = i + 1.5; }
void dpii_v_shortreal(float i, float* o) { *o = i + 1.5; }
void dpii_v_shortreal(float i, float* o) { *o = i + 1.5f; }
void dpii_v_struct (const svBitVecVal* i, svBitVecVal* o) {
o[0] = ~i[0];