[clang] [clang-repl] Undo the enumerators of an unscoped enumeration (PR #228370)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 7 09:20:13 PST 2026


================
@@ -1789,12 +1789,20 @@ void DeclContext::removeDecl(Decl *D) {
       StoredDeclsMap *Map = DC->getPrimaryContext()->LookupPtr;
       if (Map) {
         StoredDeclsMap::iterator Pos = Map->find(ND->getDeclName());
-        assert(Pos != Map->end() && "no lookup entry for decl");
-        StoredDeclsList &List = Pos->second;
-        List.remove(ND);
-        // Clean up the entry if there are no more decls.
-        if (List.isNull())
-          Map->erase(Pos);
+        // In C, the lookup table of the translation unit can miss a declaration
+        // that was declared outside of it, like a structure declared in
+        // another one (see makeDeclVisibleInContextWithFlags).
+        assert((Pos != Map->end() ||
----------------
vgvassilev wrote:

I believe it might be worth adding a C test: if we can't go via lit-level test I think we can trigger this assert with a unit test.

https://github.com/llvm/llvm-project/pull/228370


More information about the cfe-commits mailing list