Canonicalize the types produced by template argument deduction.
authorDouglas Gregor <dgregor@apple.com>
Wed, 22 Jul 2009 20:25:36 +0000 (20:25 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 22 Jul 2009 20:25:36 +0000 (20:25 +0000)
llvm-svn: 76777

clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/temp_class_spec.cpp

index 4e6d0f4..deb5457 100644 (file)
@@ -361,7 +361,8 @@ DeduceTemplateArguments(ASTContext &Context,
     assert(TemplateTypeParm->getDepth() == 0 && "Can't deduce with depth > 0");
          
     unsigned Quals = Arg.getCVRQualifiers() & ~Param.getCVRQualifiers();
-    QualType DeducedType = Arg.getQualifiedType(Quals);
+    QualType DeducedType 
+      = Context.getCanonicalType(Arg.getQualifiedType(Quals));
 
     if (Deduced[Index].isNull())
       Deduced[Index] = TemplateArgument(SourceLocation(), DeducedType);
index db154f6..b1053fe 100644 (file)
@@ -136,6 +136,24 @@ struct get_array_size<T[N]> {
 int array_size0[get_array_size<int[12]>::value == 12? 1 : -1];
 
 template<typename T>
+struct remove_extent {
+  typedef T type;
+};
+
+template<typename T>
+struct remove_extent<T[]> { 
+  typedef T type;
+};
+
+template<typename T, unsigned N>
+struct remove_extent<T[N]> { 
+  typedef T type;
+};
+
+int remove_extent0[is_same<remove_extent<int[][5]>::type, int[5]>::value? 1 : -1];
+int remove_extent1[is_same<remove_extent<const int[][5]>::type, const int[5]>::value? 1 : -1];
+
+template<typename T>
 struct is_unary_function {
   static const bool value = false;
 };