Allow ENCAPSULATED and ENUMVALUE to be disabled

This commit is contained in:
Wilson Snyder 2022-11-18 20:58:24 -05:00
parent ef72b73a59
commit b2d92b7c25
3 changed files with 26 additions and 25 deletions

View File

@ -55,8 +55,6 @@ public:
I_DEF_NETTYPE_WIRE, // `default_nettype is WIRE (false=NONE) I_DEF_NETTYPE_WIRE, // `default_nettype is WIRE (false=NONE)
I_TIMING, // Enable timing from /*verilator timing_on/off*/ I_TIMING, // Enable timing from /*verilator timing_on/off*/
// Error codes: // Error codes:
E_ENCAPSULATED, // Error: local/protected violation
E_ENUMVALUE, // Error: enum type needs explicit cast
E_PORTSHORT, // Error: Output port is connected to a constant, electrical short E_PORTSHORT, // Error: Output port is connected to a constant, electrical short
E_UNSUPPORTED, // Error: Unsupported (generally) E_UNSUPPORTED, // Error: Unsupported (generally)
E_TASKNSVAR, // Error: Task I/O not simple E_TASKNSVAR, // Error: Task I/O not simple
@ -85,12 +83,12 @@ public:
COLONPLUS, // :+ instead of +: COLONPLUS, // :+ instead of +:
COMBDLY, // Combinatorial delayed assignment COMBDLY, // Combinatorial delayed assignment
CONTASSREG, // Continuous assignment on reg CONTASSREG, // Continuous assignment on reg
DEFPARAM, // Style: Defparam
DECLFILENAME, // Declaration doesn't match filename DECLFILENAME, // Declaration doesn't match filename
DEFPARAM, // Style: Defparam
DEPRECATED, // Feature will be deprecated DEPRECATED, // Feature will be deprecated
RISEFALLDLY, // Unsupported: rise/fall/turn-off delays ENCAPSULATED, // Error: local/protected violation
MINTYPMAXDLY, // Unsupported: min/typ/max delay expressions
ENDLABEL, // End lable name mismatch ENDLABEL, // End lable name mismatch
ENUMVALUE, // Error: enum type needs explicit cast
EOFNEWLINE, // End-of-file missing newline EOFNEWLINE, // End-of-file missing newline
GENCLK, // Generated Clock. Historical, never issued. GENCLK, // Generated Clock. Historical, never issued.
HIERBLOCK, // Ignored hierarchical block setting HIERBLOCK, // Ignored hierarchical block setting
@ -106,6 +104,7 @@ public:
INSECURE, // Insecure options INSECURE, // Insecure options
LATCH, // Latch detected outside of always_latch block LATCH, // Latch detected outside of always_latch block
LITENDIAN, // Little bit endian vector LITENDIAN, // Little bit endian vector
MINTYPMAXDLY, // Unsupported: min/typ/max delay expressions
MODDUP, // Duplicate module MODDUP, // Duplicate module
MULTIDRIVEN, // Driven from multiple blocks MULTIDRIVEN, // Driven from multiple blocks
MULTITOP, // Multiple top level modules MULTITOP, // Multiple top level modules
@ -122,6 +121,7 @@ public:
RANDC, // Unsupported: 'randc' converted to 'rand' RANDC, // Unsupported: 'randc' converted to 'rand'
REALCVT, // Real conversion REALCVT, // Real conversion
REDEFMACRO, // Redefining existing define macro REDEFMACRO, // Redefining existing define macro
RISEFALLDLY, // Unsupported: rise/fall/turn-off delays
SELRANGE, // Selection index out of range SELRANGE, // Selection index out of range
SHORTREAL, // Shortreal not supported SHORTREAL, // Shortreal not supported
SPLITVAR, // Cannot split the variable SPLITVAR, // Cannot split the variable
@ -170,22 +170,22 @@ public:
// Boolean // Boolean
" I_CELLDEFINE", " I_COVERAGE", " I_TRACING", " I_LINT", " I_UNUSED", " I_DEF_NETTYPE_WIRE", " I_TIMING", " I_CELLDEFINE", " I_COVERAGE", " I_TRACING", " I_LINT", " I_UNUSED", " I_DEF_NETTYPE_WIRE", " I_TIMING",
// Errors // Errors
"ENCAPSULATED", "ENUMVALUE", "PORTSHORT", "UNSUPPORTED", "TASKNSVAR", "NEEDTIMINGOPT", "NOTIMING", "PORTSHORT", "UNSUPPORTED", "TASKNSVAR", "NEEDTIMINGOPT", "NOTIMING",
// Warnings // Warnings
" EC_FIRST_WARN", " EC_FIRST_WARN",
"ALWCOMBORDER", "ASSIGNDLY", "ASSIGNIN", "BADSTDPRAGMA", "ALWCOMBORDER", "ASSIGNDLY", "ASSIGNIN", "BADSTDPRAGMA",
"BLKANDNBLK", "BLKLOOPINIT", "BLKSEQ", "BSSPACE", "BLKANDNBLK", "BLKLOOPINIT", "BLKSEQ", "BSSPACE",
"CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CASTCONST", "CDCRSTLOGIC", "CLKDATA", "CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CASTCONST", "CDCRSTLOGIC", "CLKDATA",
"CMPCONST", "COLONPLUS", "COMBDLY", "CONTASSREG", "CMPCONST", "COLONPLUS", "COMBDLY", "CONTASSREG",
"DEFPARAM", "DECLFILENAME", "DEPRECATED", "RISEFALLDLY", "MINTYPMAXDLY", "DECLFILENAME", "DEFPARAM", "DEPRECATED",
"ENDLABEL", "EOFNEWLINE", "GENCLK", "HIERBLOCK", "ENCAPSULATED", "ENDLABEL", "ENUMVALUE", "EOFNEWLINE", "GENCLK", "HIERBLOCK",
"IFDEPTH", "IGNOREDRETURN", "IFDEPTH", "IGNOREDRETURN",
"IMPERFECTSCH", "IMPLICIT", "IMPORTSTAR", "IMPURE", "IMPERFECTSCH", "IMPLICIT", "IMPORTSTAR", "IMPURE",
"INCABSPATH", "INFINITELOOP", "INITIALDLY", "INSECURE", "INCABSPATH", "INFINITELOOP", "INITIALDLY", "INSECURE",
"LATCH", "LITENDIAN", "MODDUP", "LATCH", "LITENDIAN", "MINTYPMAXDLY", "MODDUP",
"MULTIDRIVEN", "MULTITOP","NOLATCH", "NULLPORT", "PINCONNECTEMPTY", "MULTIDRIVEN", "MULTITOP","NOLATCH", "NULLPORT", "PINCONNECTEMPTY",
"PINMISSING", "PINNOCONNECT", "PINNOTFOUND", "PKGNODECL", "PROCASSWIRE", "PINMISSING", "PINNOCONNECT", "PINNOTFOUND", "PKGNODECL", "PROCASSWIRE",
"PROFOUTOFDATE", "PROTECTED", "RANDC", "REALCVT", "REDEFMACRO", "PROFOUTOFDATE", "PROTECTED", "RANDC", "REALCVT", "REDEFMACRO", "RISEFALLDLY",
"SELRANGE", "SHORTREAL", "SPLITVAR", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET", "SELRANGE", "SHORTREAL", "SPLITVAR", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
"TICKCOUNT", "TIMESCALEMOD", "TICKCOUNT", "TIMESCALEMOD",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNOPTTHREADS", "UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNOPTTHREADS",
@ -207,8 +207,9 @@ public:
// Later -Werror- options may make more of these. // Later -Werror- options may make more of these.
bool pretendError() const VL_MT_SAFE { bool pretendError() const VL_MT_SAFE {
return (m_e == ASSIGNIN || m_e == BADSTDPRAGMA || m_e == BLKANDNBLK || m_e == BLKLOOPINIT return (m_e == ASSIGNIN || m_e == BADSTDPRAGMA || m_e == BLKANDNBLK || m_e == BLKLOOPINIT
|| m_e == CONTASSREG || m_e == ENDLABEL || m_e == IMPURE || m_e == PINNOTFOUND || m_e == CONTASSREG || m_e == ENCAPSULATED || m_e == ENDLABEL || m_e == ENUMVALUE
|| m_e == PKGNODECL || m_e == PROCASSWIRE // Says IEEE || m_e == IMPURE || m_e == PINNOTFOUND || m_e == PKGNODECL
|| m_e == PROCASSWIRE // Says IEEE
|| m_e == ZERODLY); || m_e == ZERODLY);
} }
// Warnings to mention manual // Warnings to mention manual

View File

@ -1767,7 +1767,7 @@ private:
const bool assoc = maxval > ENUM_LOOKUP_BITS; const bool assoc = maxval > ENUM_LOOKUP_BITS;
AstNode* testp = nullptr; AstNode* testp = nullptr;
FileLine* const fl_novalue = new FileLine{fl}; FileLine* const fl_novalue = new FileLine{fl};
fl_novalue->warnOff(V3ErrorCode::E_ENUMVALUE, true); fl_novalue->warnOff(V3ErrorCode::ENUMVALUE, true);
if (assoc) { if (assoc) {
AstVar* const varp = enumVarp(enumDtp, VAttrType::ENUM_VALID, true, 0); AstVar* const varp = enumVarp(enumDtp, VAttrType::ENUM_VALID, true, 0);
testp = new AstAssocSel{fl_novalue, newVarRefDollarUnit(varp), testp = new AstAssocSel{fl_novalue, newVarRefDollarUnit(varp),
@ -2767,7 +2767,7 @@ private:
0); // Spec doesn't say what to do 0); // Spec doesn't say what to do
} else { } else {
newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const
newp->dtypeFrom(adtypep); // To prevent a later E_ENUMVALUE newp->dtypeFrom(adtypep); // To prevent a later ENUMVALUE
} }
} else if (nodep->name() == "last") { } else if (nodep->name() == "last") {
const AstEnumItem* itemp = adtypep->itemsp(); const AstEnumItem* itemp = adtypep->itemsp();
@ -2777,7 +2777,7 @@ private:
0); // Spec doesn't say what to do 0); // Spec doesn't say what to do
} else { } else {
newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const
newp->dtypeFrom(adtypep); // To prevent a later E_ENUMVALUE newp->dtypeFrom(adtypep); // To prevent a later ENUMVALUE
} }
} }
UASSERT_OBJ(newp, nodep, "Enum method (perhaps enum item) not const"); UASSERT_OBJ(newp, nodep, "Enum method (perhaps enum item) not const");
@ -2825,7 +2825,7 @@ private:
AstVar* const varp = enumVarp(adtypep, attrType, true, 0); AstVar* const varp = enumVarp(adtypep, attrType, true, 0);
AstNode* const newp = new AstAssocSel{nodep->fileline(), newVarRefDollarUnit(varp), AstNode* const newp = new AstAssocSel{nodep->fileline(), newVarRefDollarUnit(varp),
nodep->fromp()->unlinkFrBack()}; nodep->fromp()->unlinkFrBack()};
newp->dtypeFrom(adtypep); // To prevent a later E_ENUMVALUE newp->dtypeFrom(adtypep); // To prevent a later ENUMVALUE
nodep->replaceWith(newp); nodep->replaceWith(newp);
} else { } else {
const int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit const int selwidth = V3Number::log2b(msbdim) + 1; // Width to address a bit
@ -2836,7 +2836,7 @@ private:
// We return "random" values if outside the range, which is fine // We return "random" values if outside the range, which is fine
// as next/previous on illegal values just need something good out // as next/previous on illegal values just need something good out
new AstSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), 0, selwidth)); new AstSel(nodep->fileline(), nodep->fromp()->unlinkFrBack(), 0, selwidth));
newp->dtypeFrom(adtypep); // To prevent a later E_ENUMVALUE newp->dtypeFrom(adtypep); // To prevent a later ENUMVALUE
nodep->replaceWith(newp); nodep->replaceWith(newp);
} }
VL_DO_DANGLING(nodep->deleteTree(), nodep); VL_DO_DANGLING(nodep->deleteTree(), nodep);
@ -6138,7 +6138,7 @@ private:
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 && warnOn) {
nodep->v3warn(E_ENUMVALUE, nodep->v3warn(ENUMVALUE,
"Illegal implicit conversion to enum " "Illegal implicit conversion to enum "
<< expDTypep->prettyDTypeNameQ() << " from " << expDTypep->prettyDTypeNameQ() << " from "
<< underp->dtypep()->prettyDTypeNameQ() << underp->dtypep()->prettyDTypeNameQ()

View File

@ -142,7 +142,7 @@ private:
if (how) { if (how) {
UINFO(9, "refclass " << refClassp << endl); UINFO(9, "refclass " << refClassp << endl);
UINFO(9, "defclass " << defClassp << endl); UINFO(9, "defclass " << defClassp << endl);
nodep->v3warn(E_ENCAPSULATED, nodep->prettyNameQ() nodep->v3warn(ENCAPSULATED, nodep->prettyNameQ()
<< " is hidden as " << how << " is hidden as " << how
<< " within this context (IEEE 1800-2017 8.18)\n" << " within this context (IEEE 1800-2017 8.18)\n"
<< nodep->warnContextPrimary() << endl << nodep->warnContextPrimary() << endl