Add support for initializing char arrays from string literals.

Adapted from a patch by Anders Carlsson.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44816 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index 5b22681..bf5ea06 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -137,3 +137,28 @@
   AryT a = { 1, 2 }, b = { 3, 4, 5 };
 }
 
+static char const xx[] = "test";
+static char const yy[5] = "test";
+static char const zz[3] = "test"; // expected-warning{{initializer-string for char array is too long}}
+
+void charArrays()
+{
+	static char const test[] = "test";
+	static char const test2[] = { "weird stuff" };
+	static char const test3[] = { "test", "excess stuff" }; // expected-error{{excess elements in char array initializer}}
+
+  char* cp[] = { "Hello" };
+
+  char c[] = { "Hello" };
+  int l[sizeof(c) == 6 ? 1 : -1];
+  
+  int i[] = { "Hello "}; // expected-error{{array of wrong type 'int' initialized from string constant}}
+  char c2[] = { "Hello", "Good bye" }; //expected-error{{excess elements in char array initializer}}
+
+  int i2[1] = { "Hello" }; //expected-error{{array of wrong type 'int' initialized from string constant}}
+  char c3[5] = { "Hello" };
+  char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}}
+
+  int i3[] = {}; //expected-error{{at least one initializer value required to size array}} expected-warning{{use of GNU empty initializer extension}}
+}
+