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,8 +6149,9 @@ private:
= VN_CAST(expDTypep->skipRefToEnump(), EnumDType)) { = VN_CAST(expDTypep->skipRefToEnump(), EnumDType)) {
const auto castable = computeCastable(expEnump, underp->dtypep(), underp); const auto castable = computeCastable(expEnump, underp->dtypep(), underp);
if (castable != COMPATIBLE && castable != ENUM_IMPLICIT && !VN_IS(underp, Cast) if (castable != COMPATIBLE && castable != ENUM_IMPLICIT && !VN_IS(underp, Cast)
&& !VN_IS(underp, CastDynamic) && !m_enumItemp && warnOn) { && !VN_IS(underp, CastDynamic) && !m_enumItemp
nodep->v3warn(ENUMVALUE, && !nodep->fileline()->warnIsOff(V3ErrorCode::ENUMVALUE) && warnOn) {
underp->v3warn(ENUMVALUE,
"Implicit conversion to enum " "Implicit conversion to enum "
<< expDTypep->prettyDTypeNameQ() << " from " << expDTypep->prettyDTypeNameQ() << " from "
<< underp->dtypep()->prettyDTypeNameQ() << underp->dtypep()->prettyDTypeNameQ()

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) %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 : ... In instance t
: ... Suggest use enum's mnemonic, or static cast : ... Suggest use enum's mnemonic, or static cast
28 | e = 1; 28 | e = 1;
| ^ | ^
... For error description see https://verilator.org/warn/ENUMVALUE?v=latest ... 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) %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 : ... In instance t
: ... Suggest use enum's mnemonic, or static cast : ... Suggest use enum's mnemonic, or static cast
29 | o = e; 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) %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 : ... In instance t
: ... Suggest use enum's mnemonic, or static cast : ... Suggest use enum's mnemonic, or static cast
35 | o = str.m_e; 35 | o = str.m_e;
| ^ | ^~~
%Error: Exiting due to %Error: Exiting due to