[cfe-commits] r120180 - in /cfe/trunk: lib/Sema/SemaCXXCast.cpp test/SemaTemplate/dependent-expr.cpp

John McCall rjmccall at apple.com
Fri Nov 26 02:57:22 PST 2010


Author: rjmccall
Date: Fri Nov 26 04:57:22 2010
New Revision: 120180

URL: http://llvm.org/viewvc/llvm-project?rev=120180&view=rev
Log:
For internal consistency's sake, compute the value kind of a dependent cast
based on the known properties of the casted-to type.  Fixes a crash on spirit.


Modified:
    cfe/trunk/lib/Sema/SemaCXXCast.cpp
    cfe/trunk/test/SemaTemplate/dependent-expr.cpp

Modified: cfe/trunk/lib/Sema/SemaCXXCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXCast.cpp?rev=120180&r1=120179&r2=120180&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCXXCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCXXCast.cpp Fri Nov 26 04:57:22 2010
@@ -161,6 +161,9 @@
       << Ex->getSourceRange();
 
   ExprValueKind VK = VK_RValue;
+  if (TypeDependent)
+    VK = Expr::getValueKindForType(DestType);
+
   switch (Kind) {
   default: llvm_unreachable("Unknown C++ cast!");
 

Modified: cfe/trunk/test/SemaTemplate/dependent-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/dependent-expr.cpp?rev=120180&r1=120179&r2=120180&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/dependent-expr.cpp (original)
+++ cfe/trunk/test/SemaTemplate/dependent-expr.cpp Fri Nov 26 04:57:22 2010
@@ -45,3 +45,10 @@
   template<typename OT> int myMethod()
   { return 2 && sizeof(OT); }
 }
+
+namespace test4 {
+  template <typename T> T *addressof(T &v) {
+    return reinterpret_cast<T*>(
+             &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
+  }
+}





More information about the cfe-commits mailing list