Several improvements from Doug Gregor related to default
argument handling.  I'll fix up the c89 (void) thing next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49459 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 5451ec2..803f527 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -833,17 +833,21 @@
   
       // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs
       // function that takes no arguments, not a function that takes a
-      // single void argument.  FIXME: Is this really the right place
-      // to check for this? C++ says that the parameter list (void) is
-      // the same as an empty parameter list, whereas the parameter
-      // list (T) (with T typedef'd to void) is not. For C++, this
-      // should be handled in the parser. Check C89 and C99 standards
-      // to see what the correct behavior is.
+      // single void argument.
       if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
           FTI.ArgInfo[0].Param &&
           !((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType().getCVRQualifiers() &&
           ((ParmVarDecl*)FTI.ArgInfo[0].Param)->getType()->isVoidType()) {
         // empty arg list, don't push any params.
+        ParmVarDecl *Param = (ParmVarDecl*)FTI.ArgInfo[0].Param;
+
+        // In C++ and C89, the empty parameter-type-list must be
+        // spelled "void"; a typedef of void is not permitted. 
+        if (!getLangOptions().C99 &&
+            Param->getType() != Context.VoidTy) {
+          Diag(Param->getLocation(), diag::ext_param_typedef_of_void);
+        }
+
       } else {
         for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
           Params.push_back((ParmVarDecl *)FTI.ArgInfo[i].Param);