Author: chandlerc
Date: Tue Dec 29 02:05:19 2009
New Revision: 92257

URL: http://llvm.org/viewvc/llvm-project?rev=92257&view=rev
Log:
Fix support for const_cast<>s of array types which actual change the
CV-qualifiers. Remove an error expectation from the 'good' set of const-cast
test cases. With this patch, the final non-template test case from PR5542
passes. (It's the same as the one already in const-cast.cpp.)

Modified:
    cfe/trunk/lib/Sema/SemaCXXCast.cpp
    cfe/trunk/test/SemaCXX/const-cast.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Tue Dec 29 02:05:19 2009
@@ -959,8 +959,9 @@
   // as must be the final pointee type.
   while (SrcType != DestType &&
          Self.UnwrapSimilarPointerTypes(SrcType, DestType)) {
-    SrcType = SrcType.getUnqualifiedType();
-    DestType = DestType.getUnqualifiedType();
+    Qualifiers Quals;
+    SrcType = Self.Context.getUnqualifiedArrayType(SrcType, Quals);
+    DestType = Self.Context.getUnqualifiedArrayType(DestType, Quals);
   }
 
   // Since we're dealing in canonical types, the remainder must be the same.

Modified: cfe/trunk/test/SemaCXX/const-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/const-cast.cpp?rev=92257&r1=92256&r2=92257&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/const-cast.cpp (original)
+++ cfe/trunk/test/SemaCXX/const-cast.cpp Tue Dec 29 02:05:19 2009
@@ -28,8 +28,9 @@
   char ***&var4 = const_cast<cpppr>(var3);
   // Drop reference. Intentionally without qualifier change.
   char *** var5 = const_cast<cppp>(var4);
+  // Const array to array reference.
   const int ar[100] = {0};
-  int (&rar)[100] = const_cast<iarr>(ar); // expected-error {{const_cast from 
'int const [100]' to 'iarr' (aka 'iar &') is not allowed}}
+  int (&rar)[100] = const_cast<iarr>(ar);
   // Array decay. Intentionally without qualifier change.
   int *pi = const_cast<int*>(ar);
   f fp = 0;


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to