From: John McCall Date: Tue, 30 Nov 2010 02:05:44 +0000 (+0000) Subject: Fix another case of giving the wrong value kind to a dependent cast to X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b4b9d6d221ab804f5b65fec6c8661be4d5c2b84;p=clang Fix another case of giving the wrong value kind to a dependent cast to a non-dependent type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120384 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 2a52f17876..214d1f6175 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -1375,13 +1375,16 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, return false; } + // Make sure we determine the value kind before we bail out for + // dependent types. + VK = Expr::getValueKindForType(CastTy); + // If the type is dependent, we won't do any other semantic analysis now. if (CastTy->isDependentType() || CastExpr->isTypeDependent()) { Kind = CK_Dependent; return false; } - VK = Expr::getValueKindForType(CastTy); if (VK == VK_RValue && !CastTy->isRecordType()) DefaultFunctionArrayLvalueConversion(CastExpr); diff --git a/test/SemaTemplate/dependent-expr.cpp b/test/SemaTemplate/dependent-expr.cpp index f3970d1d71..f26c85b1ec 100644 --- a/test/SemaTemplate/dependent-expr.cpp +++ b/test/SemaTemplate/dependent-expr.cpp @@ -52,3 +52,12 @@ namespace test4 { &const_cast(reinterpret_cast(v))); } } + +namespace test5 { + template class chained_map { + int k; + void lookup() const { + int &v = (int &)k; + } + }; +}