[cfe-commits] r92523 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp

Douglas Gregor dgregor at apple.com
Mon Jan 4 14:11:45 PST 2010


Author: dgregor
Date: Mon Jan  4 16:11:45 2010
New Revision: 92523

URL: http://llvm.org/viewvc/llvm-project?rev=92523&view=rev
Log:
Make sure to use ASTContext::getAs*ArrayType() when decomposing array
types. Fixes APFloat.cpp compilation failure.

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

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=92523&r1=92522&r2=92523&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jan  4 16:11:45 2010
@@ -996,7 +996,10 @@
   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);

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=92523&r1=92522&r2=92523&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Jan  4 16:11:45 2010
@@ -542,13 +542,13 @@
 
     //     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(),

Modified: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp?rev=92523&r1=92522&r2=92523&view=diff

==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp Mon Jan  4 16:11:45 2010
@@ -22,12 +22,14 @@
 
 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>&);





More information about the cfe-commits mailing list