]> granicus.if.org Git - clang/commitdiff
Make sure to use ASTContext::getAs*ArrayType() when decomposing array
authorDouglas Gregor <dgregor@apple.com>
Mon, 4 Jan 2010 22:11:45 +0000 (22:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 4 Jan 2010 22:11:45 +0000 (22:11 +0000)
types. Fixes APFloat.cpp compilation failure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92523 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/Sema/SemaTemplateDeduction.cpp
test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp

index bcab46d0f5ed43893d747724f35424f31ff0482f..3dcc55fbceaf1a2f0bd8acb50f265b60601fdb36 100644 (file)
@@ -996,7 +996,10 @@ public:
   const IncompleteArrayType *getAsIncompleteArrayType(QualType T) {
     return dyn_cast_or_null<IncompleteArrayType>(getAsArrayType(T));
   }
-
+  const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T) {
+    return dyn_cast_or_null<DependentSizedArrayType>(getAsArrayType(T));
+  }
+  
   /// getBaseElementType - Returns the innermost element type of an array type.
   /// For example, will return "int" for int[m][n]
   QualType getBaseElementType(const ArrayType *VAT);
index 21f79963bd895b6c8c78da1630623025e4736d93..40f3507d8b90931766ae42520dd1bba2ef913213 100644 (file)
@@ -542,13 +542,13 @@ DeduceTemplateArguments(ASTContext &Context,
 
     //     type [i]
     case Type::DependentSizedArray: {
-      const ArrayType *ArrayArg = dyn_cast<ArrayType>(Arg);
+      const ArrayType *ArrayArg = Context.getAsArrayType(Arg);
       if (!ArrayArg)
         return Sema::TDK_NonDeducedMismatch;
 
       // Check the element type of the arrays
       const DependentSizedArrayType *DependentArrayParm
-        = cast<DependentSizedArrayType>(Param);
+        = Context.getAsDependentSizedArrayType(Param);
       if (Sema::TemplateDeductionResult Result
             = DeduceTemplateArguments(Context, TemplateParams,
                                       DependentArrayParm->getElementType(),
index 9fefbe1b03686b23825a4d042fc1b94ee3a75e1a..167c67d51974b4ac8a2b84c8908f8feafc2805d0 100644 (file)
@@ -22,12 +22,14 @@ void test_f1(int i, const int ci, volatile int vi) {
 
 template<typename T, unsigned N> struct B { };
 template<typename T, unsigned N> B<T, N> g0(T (&array)[N]);
+template<typename T, unsigned N> B<T, N> g0b(const T (&array)[N]);
 
 void test_g0() {
   int array0[5];
   B<int, 5> b0 = g0(array0);
   const int array1[] = { 1, 2, 3};
   B<const int, 3> b1 = g0(array1);
+  B<int, 3> b2 = g0b(array1);
 }
 
 template<typename T> B<T, 0> g1(const A<T>&);