Fix bad-syntax crashes, bug1563.
This commit is contained in:
parent
89c3c5f952
commit
71fa09a25b
2
Changes
2
Changes
|
|
@ -18,7 +18,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, bug1557-1560. [Eric Rippey]
|
||||
**** Fix bad-syntax crashes, bug1548, bug1550-1553, bug1557-1560, bug1563. [Eric Rippey]
|
||||
|
||||
|
||||
* Verilator 4.020 2019-10-06
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ class V3PreProcImp;
|
|||
|
||||
// Token codes
|
||||
// If changing, see V3PreProc.cpp's V3PreProcImp::tokenName()
|
||||
#define VP_EOF 0
|
||||
#define VP_EOF 0 // Must be zero, a.k.a. YY_NULL, a.k.a. yy_terminate();
|
||||
#define VP_EOF_ERROR 400
|
||||
|
||||
#define VP_INCLUDE 256
|
||||
#define VP_IFDEF 257
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ bom [\357\273\277]
|
|||
/* Pass-through strings */
|
||||
<INITIAL>{quote} { yy_push_state(STRMODE); yymore(); }
|
||||
<STRMODE><<EOF>> { FL_FWDC; linenoInc(); yyerrorf("EOF in unterminated string");
|
||||
yyleng=0; yyterminate(); }
|
||||
yyleng=0; return VP_EOF_ERROR; }
|
||||
<STRMODE>{crnl} { FL_FWDC; linenoInc(); yyerrorf("Unterminated string");
|
||||
FL_BRK; BEGIN(INITIAL); }
|
||||
<STRMODE>{word} { yymore(); }
|
||||
|
|
@ -134,7 +134,7 @@ bom [\357\273\277]
|
|||
/* Stringification */
|
||||
<INITIAL>{tickquote} { FL_FWDC; yy_push_state(STRIFY); return VP_STRIFY; }
|
||||
<STRIFY><<EOF>> { FL_FWDC; linenoInc(); yyerrorf("EOF in unterminated '\"");
|
||||
yyleng=0; yyterminate(); }
|
||||
yyleng=0; return VP_EOF_ERROR; }
|
||||
<STRIFY>"`\\`\"" { FL_FWDC; return VP_BACKQUOTE; }
|
||||
<STRIFY>{quote} { yy_push_state(STRMODE); yymore(); }
|
||||
<STRIFY>{tickquote} { FL_FWDC; yy_pop_state(); return VP_STRIFY; }
|
||||
|
|
@ -152,14 +152,14 @@ bom [\357\273\277]
|
|||
/* Protected blocks */
|
||||
<INITIAL>"`protected" { yy_push_state(PRTMODE); yymore(); }
|
||||
<PRTMODE><<EOF>> { FL_FWDC; linenoInc(); yyerrorf("EOF in `protected");
|
||||
yyleng = 0; yyterminate(); }
|
||||
yyleng = 0; return VP_EOF_ERROR; }
|
||||
<PRTMODE>{crnl} { FL_FWDC; linenoInc(); return VP_TEXT; }
|
||||
<PRTMODE>. { yymore(); }
|
||||
<PRTMODE>"`endprotected" { FL_FWDC; yy_pop_state(); return VP_TEXT; }
|
||||
|
||||
/* Pass-through include <> filenames */
|
||||
<INCMODE><<EOF>> { FL_FWDC; linenoInc(); yyerrorf("EOF in unterminated include filename");
|
||||
yyleng = 0; yyterminate(); }
|
||||
yyleng = 0; return VP_EOF_ERROR; }
|
||||
<INCMODE>{crnl} { FL_FWDC; linenoInc(); yyerrorf("Unterminated include filename");
|
||||
FL_BRK; BEGIN(INITIAL); }
|
||||
<INCMODE>[^\>\\] { yymore(); }
|
||||
|
|
@ -222,13 +222,15 @@ bom [\357\273\277]
|
|||
BEGIN(CMTMODE); }
|
||||
<DEFCMT>{word} { yymore(); }
|
||||
<DEFCMT>. { yymore(); }
|
||||
<DEFCMT><<EOF>> { FL_FWDC; yyerrorf("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); }
|
||||
<DEFCMT><<EOF>> { FL_FWDC; yyerrorf("EOF in '/* ... */' block comment\n");
|
||||
yyleng=0; return VP_EOF_ERROR; }
|
||||
|
||||
/* Define arguments (use of a define) */
|
||||
<ARGMODE>"/*" { yy_push_state(CMTMODE); yymore(); }
|
||||
<ARGMODE>"//"[^\n\r]* { FL_FWDC; return VP_COMMENT; }
|
||||
<ARGMODE>{drop} { FL_FWDC; FL_BRK; }
|
||||
<ARGMODE><<EOF>> { FL_FWDC; yyerrorf("EOF in define argument list\n"); yyleng = 0; yyterminate(); }
|
||||
<ARGMODE><<EOF>> { FL_FWDC; yyerrorf("EOF in define argument list\n");
|
||||
yyleng = 0; return VP_EOF_ERROR; }
|
||||
<ARGMODE>{crnl} { FL_FWDC; linenoInc(); yytext=(char*)"\n"; yyleng=1; return VP_WHITE; }
|
||||
<ARGMODE>{quote} { yy_push_state(STRMODE); yymore(); }
|
||||
<ARGMODE>"`\\`\"" { FL_FWDC; appendDefValue(yytext, yyleng); FL_BRK; } /* Literal text */
|
||||
|
|
@ -273,7 +275,8 @@ bom [\357\273\277]
|
|||
<CMTBEGM>{ws}+ { yymore(); }
|
||||
<CMTBEGM,CMTMODE>"*/" { FL_FWDC; yy_pop_state(); return VP_COMMENT; }
|
||||
<CMTBEGM,CMTMODE>{crnl} { linenoInc(); yymore(); }
|
||||
<CMTBEGM,CMTMODE><<EOF>> { FL_FWDC; yyerrorf("EOF in '/* ... */' block comment\n"); yyleng=0; yyterminate(); }
|
||||
<CMTBEGM,CMTMODE><<EOF>> { FL_FWDC; yyerrorf("EOF in '/* ... */' block comment\n");
|
||||
yyleng=0; return VP_EOF_ERROR; }
|
||||
<CMTMODE>{word} { yymore(); }
|
||||
<CMTBEGM>. { yymore(); BEGIN CMTMODE; } /* beginning in comment */
|
||||
<CMTMODE>. { yymore(); }
|
||||
|
|
@ -285,7 +288,7 @@ bom [\357\273\277]
|
|||
|
||||
/* Generics */
|
||||
<INITIAL>{crnl} { FL_FWDC; linenoInc(); yytext=(char*)"\n"; yyleng=1; return VP_WHITE; }
|
||||
<INITIAL><<EOF>> { FL_FWDC; yyterminate(); } /* A "normal" EOF */
|
||||
<INITIAL><<EOF>> { FL_FWDC; return VP_EOF; } /* A "normal" EOF */
|
||||
<INITIAL>{symb} { FL_FWDC; return VP_SYMBOL; }
|
||||
<INITIAL>{symb}`` { FL_FWDC; yyleng-=2; return VP_SYMBOL_JOIN; }
|
||||
<INITIAL>`` { FL_FWDC; yyleng-=2; return VP_JOIN; }
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ public:
|
|||
// METHODS, called from upper level shell
|
||||
void openFile(FileLine* fl, VInFilter* filterp, const string& filename);
|
||||
bool isEof() const { return m_lexp->curStreamp()->m_eof; }
|
||||
void forceEof() { m_lexp->curStreamp()->m_eof = true; }
|
||||
string getline();
|
||||
void insertUnreadback(const string& text) { m_lineCmt += text; }
|
||||
void insertUnreadbackAtBol(const string& text);
|
||||
|
|
@ -497,6 +498,7 @@ const char* V3PreProcImp::tokenName(int tok) {
|
|||
case VP_ELSIF : return("ELSIF");
|
||||
case VP_ENDIF : return("ENDIF");
|
||||
case VP_EOF : return("EOF");
|
||||
case VP_EOF_ERROR : return("EOF_ERROR");
|
||||
case VP_ERROR : return("ERROR");
|
||||
case VP_IFDEF : return("IFDEF");
|
||||
case VP_IFNDEF : return("IFNDEF");
|
||||
|
|
@ -885,12 +887,13 @@ int V3PreProcImp::getRawToken() {
|
|||
// Snarf next token from the file
|
||||
m_lexp->curFilelinep()->startToken();
|
||||
int tok = m_lexp->lex();
|
||||
|
||||
if (debug()>=5) debugToken(tok, "RAW");
|
||||
|
||||
// A EOF on an include, so we can print `line and detect mis-matched "s
|
||||
if (tok==VP_EOF) {
|
||||
goto next_tok; // find the EOF, after adding needed lines
|
||||
if (tok==VP_EOF || tok==VP_EOF_ERROR) {
|
||||
// An error might be in an unexpected point, so stop parsing
|
||||
if (tok==VP_EOF_ERROR) forceEof();
|
||||
// A EOF on an include, stream will find the EOF, after adding needed `lines
|
||||
goto next_tok;
|
||||
}
|
||||
|
||||
if (yyourleng()) m_rawAtBol = (yyourtext()[yyourleng()-1]=='\n');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
%Error: t/t_preproc_cmtend_bad.v:9: EOF in '/* ... */' block comment
|
||||
%Error: Exiting due to
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
|
||||
scenarios(linter => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
|
||||
/*Blah
|
||||
blah
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
%Error: t/t_preproc_stringend_bad.v:7: Unterminated string
|
||||
%Error: Exiting due to
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
|
||||
scenarios(linter => 1);
|
||||
|
||||
lint(
|
||||
fails => 1,
|
||||
expect_filename => $Self->{golden_filename},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
|
||||
"Blah
|
||||
Loading…
Reference in New Issue