]> granicus.if.org Git - clang/commitdiff
When deducing the element type of an array, ignore qualifiers if
authorJohn McCall <rjmccall@apple.com>
Thu, 19 Aug 2010 00:20:19 +0000 (00:20 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 19 Aug 2010 00:20:19 +0000 (00:20 +0000)
the context allows us to ignore qualifiers on the array type itself.

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

lib/Sema/SemaTemplateDeduction.cpp
test/SemaTemplate/deduction.cpp

index 1bd041d9eff8584d130871aa5688bdefe915f338..97ad6bea336c35e9956d4363713633b4899a7045 100644 (file)
@@ -530,10 +530,11 @@ DeduceTemplateArguments(Sema &S,
       if (!IncompleteArrayArg)
         return Sema::TDK_NonDeducedMismatch;
 
+      unsigned SubTDF = TDF & TDF_IgnoreQualifiers;
       return DeduceTemplateArguments(S, TemplateParams,
                      S.Context.getAsIncompleteArrayType(Param)->getElementType(),
                                      IncompleteArrayArg->getElementType(),
-                                     Info, Deduced, 0);
+                                     Info, Deduced, SubTDF);
     }
 
     //     T [integer-constant]
@@ -548,10 +549,11 @@ DeduceTemplateArguments(Sema &S,
       if (ConstantArrayArg->getSize() != ConstantArrayParm->getSize())
         return Sema::TDK_NonDeducedMismatch;
 
+      unsigned SubTDF = TDF & TDF_IgnoreQualifiers;
       return DeduceTemplateArguments(S, TemplateParams,
                                      ConstantArrayParm->getElementType(),
                                      ConstantArrayArg->getElementType(),
-                                     Info, Deduced, 0);
+                                     Info, Deduced, SubTDF);
     }
 
     //     type [i]
@@ -560,6 +562,8 @@ DeduceTemplateArguments(Sema &S,
       if (!ArrayArg)
         return Sema::TDK_NonDeducedMismatch;
 
+      unsigned SubTDF = TDF & TDF_IgnoreQualifiers;
+
       // Check the element type of the arrays
       const DependentSizedArrayType *DependentArrayParm
         = S.Context.getAsDependentSizedArrayType(Param);
@@ -567,7 +571,7 @@ DeduceTemplateArguments(Sema &S,
             = DeduceTemplateArguments(S, TemplateParams,
                                       DependentArrayParm->getElementType(),
                                       ArrayArg->getElementType(),
-                                      Info, Deduced, 0))
+                                      Info, Deduced, SubTDF))
         return Result;
 
       // Determine the array bound is something we can deduce.
index 0dfb8d6b2cea97891bf81dd8a2b9e58531146f91..c4c668898f0fae312ae22c42a9afb7a7d87f5ecc 100644 (file)
@@ -113,3 +113,11 @@ namespace test0 {
     make(char_maker); // expected-error {{no matching function for call to 'make'}}
   }
 }
+
+namespace test1 {
+  template<typename T> void foo(const T a[3][3]);
+  void test() {
+    int a[3][3];
+    foo(a);
+  }
+}