Template argument deduction for incomplete and constant array types. Doug, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72844 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index c989132..82b027c 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -100,6 +100,35 @@
                                      Deduced);
     }
       
+    case Type::IncompleteArray: {
+      const IncompleteArrayType *IncompleteArrayArg = 
+        Context.getAsIncompleteArrayType(Arg);
+      if (!IncompleteArrayArg)
+        return false;
+      
+      return DeduceTemplateArguments(Context,
+                     Context.getAsIncompleteArrayType(Param)->getElementType(),
+                                     IncompleteArrayArg->getElementType(),
+                                     Deduced);
+    }
+    
+    case Type::ConstantArray: {
+      const ConstantArrayType *ConstantArrayArg = 
+        Context.getAsConstantArrayType(Arg);
+      if (!ConstantArrayArg)
+        return false;
+      
+      const ConstantArrayType *ConstantArrayParm = 
+        Context.getAsConstantArrayType(Param);
+      if (ConstantArrayArg->getSize() != ConstantArrayParm->getSize())
+        return false;
+      
+      return DeduceTemplateArguments(Context,
+                                     ConstantArrayParm->getElementType(),
+                                     ConstantArrayArg->getElementType(),
+                                     Deduced);
+    }
+
     default:
       break;
   }
diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp
index 710fa4a..d516f01 100644
--- a/test/SemaTemplate/temp_class_spec.cpp
+++ b/test/SemaTemplate/temp_class_spec.cpp
@@ -49,3 +49,33 @@
 int is_same1[is_same<int, INT>::value? 1 : -1];
 int is_same2[is_same<const int, int>::value? -1 : 1];
 int is_same3[is_same<int_ptr, int>::value? -1 : 1];
+
+template<typename T>
+struct is_incomplete_array {
+  static const bool value = false;
+};
+
+template<typename T>
+struct is_incomplete_array<T[]> {
+  static const bool value = true;
+};
+
+int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1];
+int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1];
+int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1];
+int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1];
+
+template<typename T>
+struct is_array_with_4_elements {
+  static const bool value = false;
+};
+
+template<typename T>
+struct is_array_with_4_elements<T[4]> {
+  static const bool value = true;
+};
+
+int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1];
+int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1];
+int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1];
+int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1];