[PCH] Fix a PCH serialization crash, with invalid code related to forward enum references.

The problem was that an enum without closing semicolon could be associated as a forward enum
in an erroneous declaration, leading to the identifier being associated with the enum decl but
without a declaration actually referencing it.
This resulted in not having it serialized before serializing the identifier that is associated with.

Also prevent the ASTUnit from querying the serialized DeclID for an invalid top-level decl; it may not
have been serialized.

rdar://14539667

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187914 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Index/pch-with-errors.m b/test/Index/pch-with-errors.m
index cc42cd3..397f8e8 100644
--- a/test/Index/pch-with-errors.m
+++ b/test/Index/pch-with-errors.m
@@ -9,6 +9,12 @@
 -(void)meth;
 @end
 
+struct FFF1
+extern I2 *somevar1;
+
+enum FFF2
+extern I2 *somevar2;
+
 #else
 
 void foo(I2 *i) {