forked from github/verilator
Fix hang on bad pattern keys, bug1364.
This commit is contained in:
parent
ad2929dff0
commit
45c9939a5e
2
Changes
2
Changes
@ -11,6 +11,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** Fix --trace-lxt2 compile error on MinGW, msg2711. [HyungKi Jeong]
|
||||
|
||||
**** Fix hang on bad pattern keys, bug1364. [Matt Myers]
|
||||
|
||||
|
||||
* Verilator 4.006 2018-10-27
|
||||
|
||||
|
@ -1756,32 +1756,39 @@ private:
|
||||
AstMemberDType* memp = classp->membersp();
|
||||
AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember);
|
||||
for (; memp || patp; ) {
|
||||
if (patp) {
|
||||
if (patp->keyp()) {
|
||||
if (AstText* textp = VN_CAST(patp->keyp(), Text)) {
|
||||
memp = classp->findMember(textp->text());
|
||||
if (!memp) {
|
||||
patp->keyp()->v3error("Assignment pattern key '"<<textp->text()<<"' not found as member");
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
patp->keyp()->v3error("Assignment pattern key not"
|
||||
" supported/understood: "<<patp->keyp()->prettyTypeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memp && !patp) {
|
||||
// Missing init elements, warn below
|
||||
memp=NULL; patp=NULL; break;
|
||||
} else if (!memp && patp) { patp->v3error("Assignment pattern contains too many elements");
|
||||
memp=NULL; patp=NULL; break;
|
||||
} else {
|
||||
std::pair<PatMap::iterator, bool> ret = patmap.insert(make_pair(memp, patp));
|
||||
if (!ret.second) {
|
||||
patp->v3error("Assignment pattern contains duplicate entry: "
|
||||
<< VN_CAST(patp->keyp(), Text)->text());
|
||||
}
|
||||
}
|
||||
do {
|
||||
if (patp) {
|
||||
if (patp->keyp()) {
|
||||
if (AstText* textp = VN_CAST(patp->keyp(), Text)) {
|
||||
memp = classp->findMember(textp->text());
|
||||
if (!memp) {
|
||||
patp->keyp()->v3error(
|
||||
"Assignment pattern key '"
|
||||
<<textp->text()<<"' not found as member");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
patp->keyp()->v3error(
|
||||
"Assignment pattern key not supported/understood: "
|
||||
<<patp->keyp()->prettyTypeName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (memp && !patp) {
|
||||
// Missing init elements, warn below
|
||||
memp=NULL; patp=NULL; break;
|
||||
} else if (!memp && patp) {
|
||||
patp->v3error("Assignment pattern contains too many elements");
|
||||
memp=NULL; patp=NULL; break;
|
||||
} else {
|
||||
std::pair<PatMap::iterator, bool> ret
|
||||
= patmap.insert(make_pair(memp, patp));
|
||||
if (!ret.second) {
|
||||
patp->v3error("Assignment pattern contains duplicate entry: "
|
||||
<< VN_CAST(patp->keyp(), Text)->text());
|
||||
}
|
||||
}
|
||||
} while(0);
|
||||
// Next
|
||||
if (memp) memp = VN_CAST(memp->nextp(), MemberDType);
|
||||
if (patp) patp = VN_CAST(patp->nextp(), PatMember);
|
||||
|
20
test_regress/t/t_array_pattern_bad.pl
Executable file
20
test_regress/t/t_array_pattern_bad.pl
Executable file
@ -0,0 +1,20 @@
|
||||
#!/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(simulator => 1);
|
||||
|
||||
compile(
|
||||
fails => 1,
|
||||
expect =>
|
||||
q{%Error: t/t_array_pattern_bad.v:23: Assignment pattern key 'valids' not found as member
|
||||
.*%Error: Exiting due to.*},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
25
test_regress/t/t_array_pattern_bad.v
Normal file
25
test_regress/t/t_array_pattern_bad.v
Normal file
@ -0,0 +1,25 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2018 by Wilson Snyder.
|
||||
|
||||
// bug1364
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk, res
|
||||
);
|
||||
input clk;
|
||||
input res;
|
||||
|
||||
typedef struct packed {
|
||||
logic [3:0] port_num;
|
||||
} info_t;
|
||||
|
||||
info_t myinfo;
|
||||
|
||||
always_comb
|
||||
myinfo = '{default: '0,
|
||||
valids: '1};
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue
Block a user