Improve diagnostic for illegal array initialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46869 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 0077691..b81f3fe 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -659,6 +659,12 @@
     // FIXME: Handle wide strings
     if (StringLiteral *strLiteral = IsStringLiteralInit(Init, DeclType))
       return CheckStringLiteralInit(strLiteral, DeclType);
+
+    if (DeclType->isArrayType())
+      return Diag(Init->getLocStart(),
+                  diag::err_array_init_list_required, 
+                  Init->getSourceRange());
+
     return CheckSingleInitializer(Init, DeclType);
   }
   unsigned newIndex = 0;
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 7e31847..3a8c04c 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -653,6 +653,8 @@
      "'extern' variable has an initializer")
 DIAG(err_variable_object_no_init, ERROR,
      "variable-sized object may not be initialized")
+DIAG(err_array_init_list_required, ERROR,
+     "initialization with \"{...}\" expected for array")
 DIAG(warn_excess_initializers, WARNING,
      "excess elements in array initializer")
 DIAG(err_excess_initializers_in_char_array_initializer, ERROR,
diff --git a/test/Sema/init.c b/test/Sema/init.c
index bbad04c..9d0d733 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -13,3 +13,7 @@
 void *g = &x;
 int *h = &x;
 
+int test() {
+int a[10];
+int b[10] = a; // expected-error {{initialization with "{...}" expected}}
+}