From: Douglas Gregor Date: Mon, 4 Jan 2010 22:11:45 +0000 (+0000) Subject: Make sure to use ASTContext::getAs*ArrayType() when decomposing array X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=442471309fa97348f849687a6a8ef4acc3bc2c1f;p=clang Make sure to use ASTContext::getAs*ArrayType() when decomposing array types. Fixes APFloat.cpp compilation failure. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92523 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index bcab46d0f5..3dcc55fbce 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -996,7 +996,10 @@ public: const IncompleteArrayType *getAsIncompleteArrayType(QualType T) { return dyn_cast_or_null(getAsArrayType(T)); } - + const DependentSizedArrayType *getAsDependentSizedArrayType(QualType T) { + return dyn_cast_or_null(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); diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 21f79963bd..40f3507d8b 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -542,13 +542,13 @@ DeduceTemplateArguments(ASTContext &Context, // type [i] case Type::DependentSizedArray: { - const ArrayType *ArrayArg = dyn_cast(Arg); + const ArrayType *ArrayArg = Context.getAsArrayType(Arg); if (!ArrayArg) return Sema::TDK_NonDeducedMismatch; // Check the element type of the arrays const DependentSizedArrayType *DependentArrayParm - = cast(Param); + = Context.getAsDependentSizedArrayType(Param); if (Sema::TemplateDeductionResult Result = DeduceTemplateArguments(Context, TemplateParams, DependentArrayParm->getElementType(), diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp index 9fefbe1b03..167c67d519 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp @@ -22,12 +22,14 @@ void test_f1(int i, const int ci, volatile int vi) { template struct B { }; template B g0(T (&array)[N]); +template B g0b(const T (&array)[N]); void test_g0() { int array0[5]; B b0 = g0(array0); const int array1[] = { 1, 2, 3}; B b1 = g0(array1); + B b2 = g0b(array1); } template B g1(const A&);