Major anonymous union/struct redesign.
A new AST node is introduced:
def IndirectField : DDecl<Value>;
IndirectFields are injected into the anonymous's parent scope and chain back to
the original field. Name lookup for anonymous entities now result in an
IndirectFieldDecl instead of a FieldDecl.
There is no functionality change, the code generated should be the same.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119919 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 9458e35..1b47332 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1429,6 +1429,11 @@
} else if (!KnownField) {
// Determine whether we found a field at all.
ReplacementField = dyn_cast<FieldDecl>(*Lookup.first);
+
+ // Check if ReplacementField is an anonymous field.
+ if (!ReplacementField)
+ if (IndirectFieldDecl* IField = dyn_cast<IndirectFieldDecl>(*Lookup.first))
+ ReplacementField = IField->getAnonField();
}
if (!ReplacementField) {