Fix bad-syntax crashes, bug1582.

This commit is contained in:
Wilson Snyder 2019-11-04 18:48:47 -05:00
parent a28896d967
commit 67d52372e5
5 changed files with 43 additions and 2 deletions

View File

@ -27,7 +27,7 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix multithreaded yield behavior when no work. [Patrick Stewart]
**** Fix bad-syntax crashes, bug1548, bug1550-1553, bug1557-1560, bug1563,
bug1573-1577. [Eric Rippey]
bug1573-1577, bug1582. [Eric Rippey]
**** Fix false CMPCONST/UNSIGNED warnings on "inside", bug1581. [Mitch Hayenga]

View File

@ -95,6 +95,7 @@ private:
// ** must track down everywhere V3Const is called and make sure no overlaps.
// AstVar::user4p -> Used by ConstVarMarkVisitor/ConstVarFindVisitor
// AstJumpLabel::user4 -> bool. Set when AstJumpGo uses this label
// AstEnum::user4 -> bool. Recursing.
// STATE
bool m_params; // If true, propagate parameterized and true numbers only
@ -1630,7 +1631,13 @@ private:
bool did = false;
if (nodep->itemp()->valuep()) {
//if (debug()) nodep->itemp()->valuep()->dumpTree(cout, " visitvaref: ");
iterateAndNextNull(nodep->itemp()->valuep());
if (nodep->itemp()->user4()) {
nodep->v3error("Recursive enum value: "<<nodep->itemp()->prettyNameQ());
} else {
nodep->itemp()->user4(true);
iterateAndNextNull(nodep->itemp()->valuep());
nodep->itemp()->user4(false);
}
if (AstConst* valuep = VN_CAST(nodep->itemp()->valuep(), Const)) {
const V3Number& num = valuep->num();
replaceNum(nodep, num); VL_DANGLING(nodep);

View File

@ -0,0 +1,10 @@
%Error: t/t_enum_recurse_bad.v:6: Recursive enum value: 'u'
enum {u=u} e_t;
^
%Error: t/t_enum_recurse_bad.v:6: Expecting expression to be constant, but variable isn't const: 'u'
enum {u=u} e_t;
^
%Error: t/t_enum_recurse_bad.v:6: Enum value isn't a constant
enum {u=u} e_t;
^
%Error: Exiting due to

View File

@ -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 2004 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(simulator => 1);
compile(
fails => 1,
expect_filename => $Self->{golden_filename},
);
ok(1);
1;

View File

@ -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.
enum {u=u} e_t;