Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about
struct/class/union/enum types when possible, either by pointing to the
forward declaration of that type or by pointing to the definition (if
we're in the process of defining that type). 
Fixes <rdar://problem/6500531>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62521 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index ea66c27..55ddb0d 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -21,7 +21,9 @@
   return sizeof(enum e) ;
 }
 
-enum gccForwardEnumExtension ve; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} expected-warning{{ISO C forbids forward references to 'enum' types}}
+enum gccForwardEnumExtension ve; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} \
+                                 // expected-warning{{ISO C forbids forward references to 'enum' types}} \
+                                 // expected-note{{forward declaration of 'enum gccForwardEnumExtension'}}
 
 int test2(int i)
 {
@@ -52,7 +54,7 @@
 
 // <rdar://problem/6093889>
 enum e0 { // expected-note {{previous definition is here}}
-  E0 = sizeof(enum e0 { E1 }) // expected-error {{nested redefinition}}
+  E0 = sizeof(enum e0 { E1 }), // expected-error {{nested redefinition}}
 };
 
 // PR3173
@@ -66,3 +68,8 @@
 
 // <rdar://problem/6503878>
 typedef enum { X = 0 }; // expected-warning{{typedef requires a name}}
+
+
+enum NotYetComplete { // expected-note{{definition of 'enum NotYetComplete' is not complete until the closing '}'}}
+  NYC1 = sizeof(enum NotYetComplete) // expected-error{{invalid application of 'sizeof' to an incomplete type 'enum NotYetComplete'}}
+};