Merge function types in C.

Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
diff --git a/clang/test/Sema/merge-decls.c b/clang/test/Sema/merge-decls.c
index da3e245..29707d2 100644
--- a/clang/test/Sema/merge-decls.c
+++ b/clang/test/Sema/merge-decls.c
@@ -48,3 +48,46 @@
   }
   (void)sizeof(*test1_f());
 }
+
+typedef int test2_IA[];
+typedef int test2_A10[10];
+
+static test2_A10 *test2_f(void);
+static test2_IA  *test2_f(void);
+
+void test2_g(void)
+{
+  (void)sizeof(*test2_f());
+}
+
+int (*test3_f())[10];
+int (*test3_f())[];
+int test3_k = sizeof(*test3_f());
+
+void test4_f(int);
+void test4_f(a)
+  char a;
+{
+  int v[sizeof(a) == 1 ? 1 : -1];
+}
+
+int test5_f(int (*)[10]);
+int test5_f(int (*x)[]) {
+  return sizeof(*x); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
+}
+
+void test6_f(int (*a)[11]);
+void test6_f(a)
+   int (*a)[];
+{}
+void test6_g() {
+  int arr[10];
+  test6_f(&arr); // expected-warning {{incompatible pointer types passing 'int (*)[10]' to parameter of type 'int (*)[11]}}
+}
+
+void test7_f(int (*)[10]);
+void test7_f(int (*)[]); // expected-note {{passing argument to parameter here}}
+void test7_g() {
+  int x[5];
+  test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
+}