[clang] [clang][Sema] fix incorrect ambiguous function call which use designated-initializer as template argument (PR #167159)

Zhikai Zeng via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 8 23:03:29 PST 2025


================
@@ -2937,6 +2937,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
     }
 
     FieldDecl *KnownField = D->getFieldDecl();
+    if (KnownField && KnownField->getParent() != RD)
+      KnownField = nullptr;
----------------
Backl1ght wrote:

> We need some comments/explanation for this workaround.
I have update a more detailed pr description.

> If this is related to cache, is it possible for us to fix that instead?
No I think, the saved FieldDecl will be used in later actions while anonymous structs/unions require us to use saved FieldDecl. Another possible way is clear the saved FieldDecl somewhere, but I can not find a proper place.

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


More information about the cfe-commits mailing list