]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: 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)
committerArthur Cohen <arthur.cohen@embecosm.com>
Wed, 19 Mar 2025 14:32:13 +0000 (15:32 +0100)
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 0a8fce34a1a9cd388cecaa60edfc607e04f2ace5..714507219e02580df0febbfed1d0ece8055e7378 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)