Sema::FinalizeDeclaratorGroup(): Tighten up the tentative definition rule when dealing with arrays.

Bug submitted by Eli.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46179 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index c2c66a2..b1753e1 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -855,10 +855,15 @@
     // external linkage is valid (C99 6.2.2p5).
     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.
-      if (T->isIncompleteType()) {
+      const VariableArrayType *VAT = T->getAsVariableArrayType();
+      
+      if (VAT && VAT->getSizeExpr() == 0) {
+        // C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
+        // array to be completed. Don't issue a diagnostic.
+      } else if (T->isIncompleteType()) {
+        // 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.
         Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
              T.getAsString());
         IDecl->setInvalidDecl();