]> granicus.if.org Git - clang/commitdiff
For internal consistency's sake, compute the value kind of a dependent cast
authorJohn McCall <rjmccall@apple.com>
Fri, 26 Nov 2010 10:57:22 +0000 (10:57 +0000)
committerJohn McCall <rjmccall@apple.com>
Fri, 26 Nov 2010 10:57:22 +0000 (10:57 +0000)
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

lib/Sema/SemaCXXCast.cpp
test/SemaTemplate/dependent-expr.cpp

index 5997d98fa58e1927f856f4c8243d772c61be1361..2a52f1787654d09f4f40c2f286011dc819fd6be3 100644 (file)
@@ -161,6 +161,9 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
       << Ex->getSourceRange();
 
   ExprValueKind VK = VK_RValue;
+  if (TypeDependent)
+    VK = Expr::getValueKindForType(DestType);
+
   switch (Kind) {
   default: llvm_unreachable("Unknown C++ cast!");
 
index e25afce77a6b080a5d314d28e591926777000b2e..f3970d1d71062b61bc60e84bf0336ddd9c8f7310 100644 (file)
@@ -45,3 +45,10 @@ namespace PR7724 {
   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)));
+  }
+}