Sema::FinalizeDeclaratorGroup()...make sure we emit an diagnostic for tentative definitions with incomplete types. Touch up all test cases that are effected.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46152 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 9e6dbfe..c2c66a2 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -853,7 +853,8 @@
     // storage-class specifier or with the storage-class specifier "static",
     // constitutes a tentative definition. Note: A tentative definition with
     // external linkage is valid (C99 6.2.2p5).
-    if (FVD && !FVD->getInit() && FVD->getStorageClass() == VarDecl::Static) {
+    if (FVD && !FVD->getInit() && (FVD->getStorageClass() == VarDecl::Static || 
+                                   FVD->getStorageClass() == VarDecl::None)) {
       // C99 6.9.2p3: If the declaration of an identifier for an object is
       // a tentative definition and has internal linkage (C99 6.2.2p3), the  
       // declared type shall not be an incomplete type.
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index df79681..8b2ce5e 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -24,7 +24,8 @@
   return a;
 }
 
-int foo[](void);  // expected-error {{'foo' declared as array of functions}}
+int foo[](void);  // expected-error {{variable has incomplete type 'int (*[])(void)'}} expected-error {{'foo' declared as array of functions}}
+int foo2[1](void);  // expected-error {{'foo2' declared as array of functions}}
 
 typedef int (*pfunc)(void);
 
diff --git a/test/Sema/deref.c b/test/Sema/deref.c
index 87f1b48..7441584 100644
--- a/test/Sema/deref.c
+++ b/test/Sema/deref.c
@@ -17,6 +17,6 @@
 void foo3 (void)
 {
  void* x = 0;
- void* y = &*x; // expected-error {{invalid lvalue in address expression}}
+ void* y = &*x; // expected-error {{address expression must be an lvalue or a function designator}}
 }
 
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index 169c394..890b6a5 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -22,9 +22,9 @@
   return sizeof(enum e) ;
 }
 
-enum gccForwardEnumExtension ve; // 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}}
 
 int test2(int i)
 {
-  ve + i; // expected-error{{invalid operands to binary expression ('enum gccForwardEnumExtension' and 'int')}}
+  ve + i;
 }
diff --git a/test/Sema/incomplete-decl.c b/test/Sema/incomplete-decl.c
new file mode 100644
index 0000000..e342ab8
--- /dev/null
+++ b/test/Sema/incomplete-decl.c
@@ -0,0 +1,15 @@
+// RUN: clang -fsyntax-only -verify %s
+
+void b;  // expected-error {{variable has incomplete type 'void'}}
+struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
+
+static void c; // expected-error {{variable has incomplete type 'void'}}
+static struct foo g;  // expected-error {{variable has incomplete type 'struct foo'}}
+
+extern void d;
+extern struct foo e;
+
+void func() {
+  void b; // expected-error {{variable has incomplete type 'void'}}
+  struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
+}