Handle invalid old-style UDP tables
An empty old-style UDP table leaves the parsed table pointer unset after the parser reports the table error. The old-style UDP creation path still passed the null pointer to process_udp_table(), which crashes. Report an invalid UDP table instead and do not register the primitive. Also keep the new-style invalid-table diagnostic formatting consistent. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
4b9675abd7
commit
20a969bf38
|
|
@ -1,4 +1,3 @@
|
|||
./ivltests/br_gh1175c.v:3: syntax error
|
||||
./ivltests/br_gh1175c.v:3: errors in UDP table
|
||||
./ivltests/br_gh1175c.v:1: error: Invalid table for UDP primitive id_0.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
./ivltests/br_gh1175d.v:3: syntax error
|
||||
./ivltests/br_gh1175d.v:3: errors in UDP table
|
||||
./ivltests/br_gh1175d.v:1: error: Invalid table for UDP primitive id_0.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
./ivltests/br_gh1175e.v:3: syntax error
|
||||
./ivltests/br_gh1175e.v:3: errors in UDP table
|
||||
./ivltests/br_gh1175e.v:1: error: Invalid table for UDP primitive id_0.
|
||||
|
||||
|
|
|
|||
16
pform.cc
16
pform.cc
|
|
@ -2079,10 +2079,18 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
for (unsigned idx = 0 ; idx < pins.size() ; idx += 1)
|
||||
udp->ports[idx] = pins[idx]->basename();
|
||||
|
||||
process_udp_table(udp, table, loc);
|
||||
udp->initial = init;
|
||||
if (table) {
|
||||
process_udp_table(udp, table, loc);
|
||||
udp->initial = init;
|
||||
|
||||
pform_primitives[name] = udp;
|
||||
pform_primitives[name] = udp;
|
||||
} else {
|
||||
ostringstream msg;
|
||||
msg << "error: Invalid table for UDP primitive " << name
|
||||
<< ".";
|
||||
VLerror(loc, msg.str().c_str(), "");
|
||||
delete udp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2172,7 +2180,7 @@ void pform_make_udp(const struct vlltype&loc, perm_string name,
|
|||
} else {
|
||||
ostringstream msg;
|
||||
msg << "error: Invalid table for UDP primitive " << name
|
||||
<< "." << endl;
|
||||
<< ".";
|
||||
// Some compilers warn if there is just a single C string.
|
||||
VLerror(loc, msg.str().c_str(), "");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue