From: John McCall Date: Fri, 26 Nov 2010 10:57:22 +0000 (+0000) Subject: For internal consistency's sake, compute the value kind of a dependent cast X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a21e06cb62dbd806073f646e756e89d8e23fc1c3;p=clang 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 5997d98fa5..2a52f17876 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -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!"); diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp index e25afce77a..f3970d1d71 100644 --- a/test/SemaTemplate/dependent-expr.cpp +++ b/test/SemaTemplate/dependent-expr.cpp @@ -45,3 +45,10 @@ namespace PR7724 { template int myMethod() { return 2 && sizeof(OT); } } + +namespace test4 { + template T *addressof(T &v) { + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); + } +}