Attempt to fix a read-after-free running test/Sema/designated-initializers.c.
Douglas, can you check that this is doing the right thing?
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index a0f4e4a..28b2556 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1234,15 +1234,15 @@
ExpandAnonymousFieldDesignator(SemaRef, DIE, DesigIdx,
cast<FieldDecl>(*Lookup.first),
Field, FieldIndex);
+ D = DIE->getDesignator(DesigIdx);
} else {
// Name lookup found something, but it wasn't a field.
SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield)
<< FieldName;
SemaRef.Diag((*Lookup.first)->getLocation(),
diag::note_field_designator_found);
-
- ++Index;
- return true;
+ ++Index;
+ return true;
}
} else if (!KnownField &&
cast<RecordDecl>((*Field)->getDeclContext())