Fix rdar://6821047 - clang crashes on subscript of interface in 64-bit mode

Several changes here:
1. We change Type::isIncompleteType to realize that forward declared 
   interfaces are incomplete.  This eliminate special case code for this
   from the sizeof path, and starts us rejecting P[4] when P is a pointer
   to an incomplete interface.
2. Explicitly reject P[4] when P points to an interface in non-fragile ABI
   mode.
3. Switch the sizeof(interface) diagnostic back to an error instead of a 
   warning in non-fragile abi mode.

llvm-svn: 69943
diff --git a/clang/test/SemaObjC/sizeof-interface.m b/clang/test/SemaObjC/sizeof-interface.m
index ac029fd..1793167 100644
--- a/clang/test/SemaObjC/sizeof-interface.m
+++ b/clang/test/SemaObjC/sizeof-interface.m
@@ -3,9 +3,17 @@
 @class I0;
 
 // rdar://6811884
-int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to a forward declared interface 'I0'}}
+int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}}
+
+// rdar://6821047
+void *g3(I0 *P) {
+  return &P[4];   // expected-error{{subscript of pointer to incomplete type 'I0'}}
+}
+
+
 
 @interface I0 {
+@public
   char x[4];
 }
 
@@ -13,7 +21,7 @@
 @end
 
 // size == 4
-int g1[ sizeof(I0)     // expected-warning {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
+int g1[ sizeof(I0)     // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
        == 4 ? 1 : -1];
 
 @implementation I0
@@ -22,7 +30,7 @@
 
 // size == 4 (we do not include extended properties in the
 // sizeof).
-int g2[ sizeof(I0)   // expected-warning {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
+int g2[ sizeof(I0)   // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}}
        == 4 ? 1 : -1];
 
 @interface I1
@@ -38,3 +46,9 @@
 // FIXME: This is currently broken due to the way the record layout we
 // create is tied to whether we have seen synthesized properties. Ugh.
 // int g3[ sizeof(I1) == 0 ? 1 : -1];
+
+// rdar://6821047
+int bar(I0 *P) {
+  return P[4].x[2];  // expected-error {{subscript requires size of interface 'I0', which is not constant in non-fragile ABI}}
+}
+