From 8adc14d22b0b0d0d16e7540c31cfe4ea39f0b5a2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 9 Sep 2023 22:13:05 +0200 Subject: [PATCH] Fixing issue-1474 (throw a FATAL ERROR when multiple cellname have the same refnum) --- src/db/db/dbCommonReader.cc | 8 ++++---- .../oasis/unit_tests/dbOASISReaderTests.cc | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/db/db/dbCommonReader.cc b/src/db/db/dbCommonReader.cc index 44484f383..15599a1f5 100644 --- a/src/db/db/dbCommonReader.cc +++ b/src/db/db/dbCommonReader.cc @@ -150,11 +150,11 @@ CommonReaderBase::rename_cell (db::Layout &layout, size_t id, const std::string std::map >::iterator iid = m_id_map.find (id); std::map >::iterator iname = m_name_map.find (cn); - if (iid != m_id_map.end () && iname != m_name_map.end ()) { + if (iid != m_id_map.end () && ! iid->second.first.empty () && iid->second.first != cn) { + common_reader_error (tl::sprintf (tl::to_string (tr ("Cell named %s with ID %ld was already given name %s")), cn, id, iid->second.first)); + } - if (! iid->second.first.empty () && iid->second.first != cn) { - common_reader_error (tl::sprintf (tl::to_string (tr ("Cell named %s with ID %ld was already given name %s")), cn, id, iid->second.first)); - } + if (iid != m_id_map.end () && iname != m_name_map.end ()) { if (iname->second.second != iid->second.second) { diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc index f0bd51675..3ef9f1dfe 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc @@ -584,3 +584,18 @@ TEST(Bug_121_2) std::string fn_au (tl::testdata () + "/oasis/bug_121_au2.gds"); db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); } + +TEST(Bug_1474) +{ + db::Manager m (false); + db::Layout layout (&m); + + try { + tl::InputStream file (tl::testdata_private () + "/oasis/issue_1474.oas"); + db::OASISReader reader (file); + reader.read (layout); + EXPECT_EQ (false, true); + } catch (tl::Exception &ex) { + EXPECT_EQ (ex.msg (), "Cell named ADDHX2 with ID 4 was already given name SEDFFTRX2 (position=763169, cell=)"); + } +}