Fix http://llvm.org/bugs/show_bug.cgi?id=2161.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48568 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 84fe081..02b5f31 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1089,8 +1089,19 @@
     // empty arg list, don't push any params.
   } else {
     for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) {
-      Params.push_back(ActOnParamDeclarator(D.getTypeObject(0).Fun.ArgInfo[i],
-                                            FnBodyScope));
+      ParmVarDecl *parmDecl;
+      
+      parmDecl = ActOnParamDeclarator(D.getTypeObject(0).Fun.ArgInfo[i],
+                                      FnBodyScope);
+      // C99 6.7.5.3p4: the parameters in a parameter type list in a function
+      // declarator that is part of a function definition of that function
+      // shall not have incomplete type.
+      if (parmDecl->getType()->isIncompleteType()) {
+        Diag(parmDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
+             parmDecl->getType().getAsString());
+        parmDecl->setInvalidDecl();
+      }
+      Params.push_back(parmDecl);
     }
   }