diff --git a/Changes b/Changes index cc83c659d..781e6d37e 100644 --- a/Changes +++ b/Changes @@ -16,7 +16,7 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix multithreaded yield behavior when no work. [Patrick Stewart] -**** Fix misc bad-syntax crashes, bug1548, bug1550-1553. [Eric Rippey] +**** Fix misc bad-syntax crashes, bug1548, bug1550-1553, bug1557-1560. [Eric Rippey] * Verilator 4.020 2019-10-06 diff --git a/src/V3FileLine.cpp b/src/V3FileLine.cpp index 574c8e3be..98ce6834d 100644 --- a/src/V3FileLine.cpp +++ b/src/V3FileLine.cpp @@ -377,8 +377,8 @@ string FileLine::warnContext(bool secondary) const { out += sourceLine+"\n"; out += string((firstColumn()-1), ' ')+'^'; // Can't use UASSERT_OBJ used in warnings already inside the error end handler - UASSERT_STATIC(lastColumn() >= firstColumn(), "Column numbers backwards"); - if (lastColumn() != firstColumn()) { + if (lastColumn() > firstColumn()) { + // Note lastColumn() can be <= firstColumn() in some weird preproc expansions out += string((lastColumn()-firstColumn()-1), '~'); } out += "\n"; diff --git a/src/verilog.y b/src/verilog.y index b2f3bdab6..d3520f433 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -192,6 +192,7 @@ int V3ParseGrammar::s_modTypeImpNum = 0; // Macro functions #define CRELINE() (PARSEP->copyOrSameFileLine()) // Only use in empty rules, so lines point at beginnings +#define FILELINE_OR_CRE(nodep) ((nodep) ? (nodep)->fileline() : CRELINE()) #define VARRESET_LIST(decl) { GRAMMARP->m_pinNum=1; GRAMMARP->m_pinAnsi=false; \ VARRESET(); VARDECL(decl); } // Start of pinlist @@ -2297,7 +2298,7 @@ cellpinItemE: // IEEE: named_port_connection + empty //UNSUP '.' idAny '(' expr ':' expr ')' { } //UNSUP '.' idAny '(' expr ':' expr ':' expr ')' { } // - | expr { $$ = new AstPin($1->fileline(),PINNUMINC(),"",$1); } + | expr { $$ = new AstPin(FILELINE_OR_CRE($1),PINNUMINC(),"",$1); } //UNSUP expr ':' expr { } //UNSUP expr ':' expr ':' expr { } ; @@ -2741,7 +2742,7 @@ assignment_pattern: // ==IEEE: assignment_pattern // // also IEEE "''{' array_pattern_key ':' ... | yP_TICKBRA patternMemberList '}' { $$ = new AstPattern($1,$2); } // // IEEE: Not in grammar, but in VMM - | yP_TICKBRA '}' { $$ = NULL; $1->v3error("Unsupported: Empty '{}"); } + | yP_TICKBRA '}' { $$ = new AstPattern($1, NULL); $1->v3error("Unsupported: Empty '{}"); } ; // "datatype id = x {, id = x }" | "yaId = x {, id=x}" is legal