Fix overshift error to have user's source line.

This commit is contained in:
Wilson Snyder 2019-06-15 07:43:45 -04:00
parent 5da5e32e86
commit 0d71c1154d
3 changed files with 12 additions and 7 deletions

View File

@ -35,7 +35,7 @@
//======================================================================
// Errors
void V3Number::v3errorEnd(std::ostringstream& str) {
void V3Number::v3errorEnd(std::ostringstream& str) const {
std::ostringstream nsstr;
nsstr<<str.str();
m_fileline->v3errorEnd(nsstr);
@ -665,7 +665,10 @@ uint32_t V3Number::toUInt() const {
UASSERT(!isFourState(), "toUInt with 4-state "<<*this);
// We allow wide numbers that represent values <= 32 bits
for (int i=1; i<words(); ++i) {
UASSERT(!m_value[i], "Value too wide for 32-bits expected in this context "<<*this);
if (m_value[i]) {
v3error("Value too wide for 32-bits expected in this context "<<*this);
break;
}
}
return m_value[0];
}
@ -699,7 +702,10 @@ vluint64_t V3Number::toUQuad() const {
UASSERT(!isFourState(), "toUQuad with 4-state "<<*this);
// We allow wide numbers that represent values <= 64 bits
for (int i=2; i<words(); ++i) {
UASSERT(!m_value[i], "Value too wide for 64-bits expected in this context "<<*this);
if (m_value[i]) {
v3error("Value too wide for 64-bits expected in this context "<<*this);
break;
}
}
if (width()<=32) return (static_cast<vluint64_t>(toUInt()));
return ((static_cast<vluint64_t>(m_value[1])<<VL_ULL(32))

View File

@ -179,7 +179,7 @@ private:
return displayed(m_fileline, vformat);
}
public:
void v3errorEnd(std::ostringstream& sstr);
void v3errorEnd(std::ostringstream& sstr) const;
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; }

View File

@ -1,3 +1,2 @@
%Error: Internal Error: ../V3Number.cpp:668: Value too wide for 32-bits expected in this context 64'h123456789abcdef
... See the manual and http://www.veripool.org/verilator for more assistance.
%Error: Command Failed
%Error: t/t_math_shift_over_bad.v:18: Value too wide for 32-bits expected in this context 64'h123456789abcdef
%Error: Exiting due to