aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCXXCast.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-04-10 19:13:55 +0000
committerJohn McCall <rjmccall@apple.com>2011-04-10 19:13:55 +0000
commitfb8721ce4c6fef3739b1cbd1e38e3f1949462033 (patch)
tree54f0addce9b93c4e981327b42e9d235c3f3aa575 /lib/Sema/SemaCXXCast.cpp
parentcd0b32e73a66a20a8dab7a7f0ce963dc669f7c0a (diff)
Simplify calling CheckPlaceholderExpr, converge on it in a few places,
and move a vector-splat check to follow l-value conversion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r--lib/Sema/SemaCXXCast.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp
index 989be96d21..31a772a5d8 100644
--- a/lib/Sema/SemaCXXCast.cpp
+++ b/lib/Sema/SemaCXXCast.cpp
@@ -1526,37 +1526,26 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK,
// a non-lvalue-reference target type does not lead to decay.
// C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void".
if (CastTy->isVoidType()) {
+ Kind = CK_ToVoid;
+
ExprResult CastExprRes = IgnoredValueConversions(CastExpr);
if (CastExprRes.isInvalid())
return ExprError();
CastExpr = CastExprRes.take();
- bool ret = false; // false is 'able to convert'
+
if (CastExpr->getType() == Context.OverloadTy) {
ExprResult SingleFunctionExpr =
ResolveAndFixSingleFunctionTemplateSpecialization(
CastExpr, /* Decay Function to ptr */ false,
/* Complain */ true, R, CastTy,
diag::err_bad_cstyle_cast_overload);
-
- if (SingleFunctionExpr.isUsable()) {
- CastExpr = SingleFunctionExpr.take();
- Kind = CK_ToVoid;
- }
- else
- ret = true;
+ if (SingleFunctionExpr.isInvalid())
+ return ExprError();
+ CastExpr = SingleFunctionExpr.take();
}
- else
- Kind = CK_ToVoid;
- return ret ? ExprError() : Owned(CastExpr);
- }
- // Case of AltiVec vector initialization with a single literal
- if (CastTy->isVectorType()
- && CastTy->getAs<VectorType>()->getVectorKind() ==
- VectorType::AltiVecVector
- && (CastExpr->getType()->isIntegerType()
- || CastExpr->getType()->isFloatingType())) {
- Kind = CK_VectorSplat;
+ assert(!CastExpr->getType()->isPlaceholderType());
+
return Owned(CastExpr);
}
@@ -1577,6 +1566,15 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK,
CastExpr = CastExprRes.take();
}
+ // AltiVec vector initialization with a single literal.
+ if (const VectorType *vecTy = CastTy->getAs<VectorType>())
+ if (vecTy->getVectorKind() == VectorType::AltiVecVector
+ && (CastExpr->getType()->isIntegerType()
+ || CastExpr->getType()->isFloatingType())) {
+ Kind = CK_VectorSplat;
+ return Owned(CastExpr);
+ }
+
// C++ [expr.cast]p5: The conversions performed by
// - a const_cast,
// - a static_cast,