]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix missing error on duplicated nodes
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 21 Aug 2024 15:01:29 +0000 (17:01 +0200)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Thu, 26 Sep 2024 22:48:32 +0000 (22:48 +0000)
When we tried to insert a shadowable node and another shadowable node has
been inserted before, we didn't emit any error if the node has already
been inserted previously and failed silently.

gcc/rust/ChangeLog:

* resolve/rust-rib.cc (Rib::insert): Emit an error when trying to
insert an already inserted node.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-rib.cc

index a73e2bd6f7571f8fa44f8d754a6f9b85d7204d9c..945e1c333caf46ccc76f9ac557838c43be1cb9c0 100644 (file)
@@ -92,9 +92,9 @@ Rib::insert (std::string name, Definition def)
        {
          if (std::find (current.ids.cbegin (), current.ids.cend (), id)
              == current.ids.cend ())
-           {
-             current.ids.push_back (id);
-           }
+           current.ids.push_back (id);
+         else
+           return tl::make_unexpected (DuplicateNameError (name, id));
        }
     }
   else if (it->second.shadowable)