Implement C99 6.7.5.3p1


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45188 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaType.cpp b/Sema/SemaType.cpp
index 8a5cfaa..fa9c9ed 100644
--- a/Sema/SemaType.cpp
+++ b/Sema/SemaType.cpp
@@ -262,6 +262,15 @@
       // does not have a K&R-style identifier list), then the arguments are part
       // of the type, otherwise the argument list is ().
       const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
+        
+      // C99 6.7.5.3p1: The return type may not be a function or array type.
+      if (T->isArrayType() || T->isFunctionType()) {
+        Diag(DeclType.Loc, diag::err_func_returning_array_function,
+             T.getAsString());
+        T = Context.IntTy;
+        D.setInvalidType(true);
+      }
+        
       if (!FTI.hasPrototype) {
         // Simple void foo(), where the incoming T is the result type.
         T = Context.getFunctionTypeNoProto(T);