Switching to using dyn_cast_or_null, and fixing line endings in the test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150209 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 759fb16..6fff123 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1511,8 +1511,8 @@
IdentifierInfo *FieldName) {
assert(AnonField->isAnonymousStructOrUnion());
Decl *NextDecl = AnonField->getNextDeclInContext();
- IndirectFieldDecl *IF = NULL;
- while (NextDecl && (IF = dyn_cast<IndirectFieldDecl>(NextDecl))) {
+ while (IndirectFieldDecl *IF =
+ dyn_cast_or_null<IndirectFieldDecl>(NextDecl)) {
if (FieldName && FieldName == IF->getAnonField()->getIdentifier())
return IF;
NextDecl = NextDecl->getNextDeclInContext();
diff --git a/test/Sema/init.c b/test/Sema/init.c
index 4dcfafa..81a665d 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -18,12 +18,12 @@
void *g = &x;
int *h = &x;
-struct union_crash
-{
- union
- {
- };
-};
+struct union_crash
+{
+ union
+ {
+ };
+};
int test() {
int a[10];