Fix ENUMVALUE error to show value location (#3783)

This commit is contained in:
Wilson Snyder 2022-11-27 08:44:30 -05:00
parent c303ba7f0a
commit 054b792021
2 changed files with 18 additions and 17 deletions

View File

@ -6149,14 +6149,15 @@ private:
= VN_CAST(expDTypep->skipRefToEnump(), EnumDType)) {
const auto castable = computeCastable(expEnump, underp->dtypep(), underp);
if (castable != COMPATIBLE && castable != ENUM_IMPLICIT && !VN_IS(underp, Cast)
&& !VN_IS(underp, CastDynamic) && !m_enumItemp && warnOn) {
nodep->v3warn(ENUMVALUE,
"Implicit conversion to enum "
<< expDTypep->prettyDTypeNameQ() << " from "
<< underp->dtypep()->prettyDTypeNameQ()
<< " (IEEE 1800-2017 6.19.3)\n"
<< nodep->warnMore()
<< "... Suggest use enum's mnemonic, or static cast");
&& !VN_IS(underp, CastDynamic) && !m_enumItemp
&& !nodep->fileline()->warnIsOff(V3ErrorCode::ENUMVALUE) && warnOn) {
underp->v3warn(ENUMVALUE,
"Implicit conversion to enum "
<< expDTypep->prettyDTypeNameQ() << " from "
<< underp->dtypep()->prettyDTypeNameQ()
<< " (IEEE 1800-2017 6.19.3)\n"
<< nodep->warnMore()
<< "... Suggest use enum's mnemonic, or static cast");
if (debug()) nodep->backp()->dumpTree("- back: ");
}
}

View File

@ -1,17 +1,17 @@
%Error-ENUMVALUE: t/t_enum_type_bad.v:28:9: Implicit conversion to enum 't.e_t' from 'logic[31:0]' (IEEE 1800-2017 6.19.3)
: ... In instance t
%Error-ENUMVALUE: t/t_enum_type_bad.v:28:11: Implicit conversion to enum 't.e_t' from 'logic[31:0]' (IEEE 1800-2017 6.19.3)
: ... In instance t
: ... Suggest use enum's mnemonic, or static cast
28 | e = 1;
| ^
| ^
... For error description see https://verilator.org/warn/ENUMVALUE?v=latest
%Error-ENUMVALUE: t/t_enum_type_bad.v:29:9: Implicit conversion to enum 't.o_t' from 't.e_t' (IEEE 1800-2017 6.19.3)
: ... In instance t
%Error-ENUMVALUE: t/t_enum_type_bad.v:29:11: Implicit conversion to enum 't.o_t' from 't.e_t' (IEEE 1800-2017 6.19.3)
: ... In instance t
: ... Suggest use enum's mnemonic, or static cast
29 | o = e;
| ^
%Error-ENUMVALUE: t/t_enum_type_bad.v:35:9: Implicit conversion to enum 't.o_t' from 'ENUMDTYPE 't.e_t'' (IEEE 1800-2017 6.19.3)
: ... In instance t
| ^
%Error-ENUMVALUE: t/t_enum_type_bad.v:35:15: Implicit conversion to enum 't.o_t' from 'ENUMDTYPE 't.e_t'' (IEEE 1800-2017 6.19.3)
: ... In instance t
: ... Suggest use enum's mnemonic, or static cast
35 | o = str.m_e;
| ^
| ^~~
%Error: Exiting due to