From ec1eea9990152608c32614655ff315222fa11201 Mon Sep 17 00:00:00 2001 From: Gary Wong Date: Sun, 5 Apr 2020 21:35:21 -0600 Subject: [PATCH] Fix assertion failure on invalid LOCATE input. Trying to parse this invalid LPF syntax: LOCATE COMP "a" SITE "A1" IOBUF PORT "a" IO_TYPE=LVCMOS33; (note missing semicolon on first line) gives an assertion failure in strip_quotes, because the fifth token is scanned as "A1"IOBUF (without a trailing quote). Avoid the problem by detecting extraneous input and issuing a more specific error. --- ecp5/lpf.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ecp5/lpf.cc b/ecp5/lpf.cc index ceb1d7ae..e626cc54 100644 --- a/ecp5/lpf.cc +++ b/ecp5/lpf.cc @@ -101,6 +101,8 @@ bool Arch::applyLPF(std::string filename, std::istream &in) if (words.at(3) != "SITE") log_error("expected 'SITE' after 'LOCATE COMP %s' (on line %d)\n", cell.c_str(), lineno); auto fnd_cell = cells.find(id(cell)); + if (words.size() > 5) + log_error("unexpected input following LOCATE clause (on line %d)\n", lineno); if (fnd_cell != cells.end()) { fnd_cell->second->attrs[id("LOC")] = strip_quotes(words.at(4)); }