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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120180 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index 5997d98..2a52f17 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -161,6 +161,9 @@
       << Ex->getSourceRange();
 
   ExprValueKind VK = VK_RValue;
+  if (TypeDependent)
+    VK = Expr::getValueKindForType(DestType);
+
   switch (Kind) {
   default: llvm_unreachable("Unknown C++ cast!");
 
diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp
index e25afce..f3970d1 100644
--- a/test/SemaTemplate/dependent-expr.cpp
+++ b/test/SemaTemplate/dependent-expr.cpp
@@ -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)));
+  }
+}