// 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);
}
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,
Diag(OpLoc, diag::err_sizeof_alignof_bitfield) << 0;
isInvalid = true;
} else if (E->getType()->isPlaceholderType()) {
- ExprResult PE = CheckPlaceholderExpr(E, OpLoc);
+ ExprResult PE = CheckPlaceholderExpr(E);
if (PE.isInvalid()) return ExprError();
return CreateUnaryExprOrTypeTraitExpr(PE.take(), OpLoc, ExprKind, R);
} else {
return V.get()->getType();
// Test for placeholders.
- ExprResult PR = S.CheckPlaceholderExpr(V.get(), Loc);
+ ExprResult PR = S.CheckPlaceholderExpr(V.get());
if (PR.isInvalid()) return QualType();
if (PR.get() != V.get()) {
V = move(PR);
argTypes.reserve(numArgs);
for (unsigned i = 0; i != numArgs; ++i) {
// Require all the sub-expression to not be placeholders.
- ExprResult result = S.CheckPlaceholderExpr(args[i], SourceLocation());
+ ExprResult result = S.CheckPlaceholderExpr(args[i]);
if (result.isInvalid()) return ExprError();
args[i] = result.take();
castType, VK, castExpr, Kind, BasePath,
FunctionalStyle);
+ assert(!castExpr->getType()->isPlaceholderType());
+
// We only support r-value casts in C.
VK = VK_RValue;
ExprValueKind &VK, ExprObjectKind &OK,
SourceLocation QuestionLoc) {
- ExprResult lhsResult = CheckPlaceholderExpr(LHS.get(), QuestionLoc);
+ ExprResult lhsResult = CheckPlaceholderExpr(LHS.get());
if (!lhsResult.isUsable()) return QualType();
LHS = move(lhsResult);
- ExprResult rhsResult = CheckPlaceholderExpr(RHS.get(), QuestionLoc);
+ ExprResult rhsResult = CheckPlaceholderExpr(RHS.get());
if (!rhsResult.isUsable()) return QualType();
RHS = move(rhsResult);
SourceLocation Loc) {
S.DiagnoseUnusedExprResult(LHS.get());
- LHS = S.CheckPlaceholderExpr(LHS.take(), Loc);
- RHS = S.CheckPlaceholderExpr(RHS.take(), Loc);
+ LHS = S.CheckPlaceholderExpr(LHS.take());
+ RHS = S.CheckPlaceholderExpr(RHS.take());
if (LHS.isInvalid() || RHS.isInvalid())
return QualType();
S.Diag(OpLoc, diag::ext_integer_increment_complex)
<< ResType << Op->getSourceRange();
} else if (ResType->isPlaceholderType()) {
- ExprResult PR = S.CheckPlaceholderExpr(Op, OpLoc);
+ ExprResult PR = S.CheckPlaceholderExpr(Op);
if (PR.isInvalid()) return QualType();
return CheckIncrementDecrementOperand(S, PR.take(), VK, OpLoc,
isInc, isPrefix);
if (OrigOp->getType() == S.Context.OverloadTy)
return S.Context.OverloadTy;
- ExprResult PR = S.CheckPlaceholderExpr(OrigOp, OpLoc);
+ ExprResult PR = S.CheckPlaceholderExpr(OrigOp);
if (PR.isInvalid()) return QualType();
OrigOp = PR.take();
OpTy->getAs<ObjCObjectPointerType>())
Result = OPT->getPointeeType();
else {
- ExprResult PR = S.CheckPlaceholderExpr(Op, OpLoc);
+ ExprResult PR = S.CheckPlaceholderExpr(Op);
if (PR.isInvalid()) return QualType();
if (PR.take() != Op)
return CheckIndirectionOperand(S, PR.take(), VK, OpLoc);
// f<int> == 0; // resolve f<int> blindly
// void (*p)(int); p = f<int>; // resolve f<int> using target
if (Opc != BO_Assign) {
- ExprResult resolvedLHS = CheckPlaceholderExpr(lhs.get(), OpLoc);
+ ExprResult resolvedLHS = CheckPlaceholderExpr(lhs.get());
if (!resolvedLHS.isUsable()) return ExprError();
lhs = move(resolvedLHS);
- ExprResult resolvedRHS = CheckPlaceholderExpr(rhs.get(), OpLoc);
+ ExprResult resolvedRHS = CheckPlaceholderExpr(rhs.get());
if (!resolvedRHS.isUsable()) return ExprError();
rhs = move(resolvedRHS);
}
resultType = CheckAddressOfOperand(*this, Input.get(), OpLoc);
break;
case UO_Deref: {
- ExprResult resolved = CheckPlaceholderExpr(Input.get(), OpLoc);
+ ExprResult resolved = CheckPlaceholderExpr(Input.get());
if (!resolved.isUsable()) return ExprError();
Input = move(resolved);
Input = DefaultFunctionArrayLvalueConversion(Input.take());
resultType->isPointerType())
break;
else if (resultType->isPlaceholderType()) {
- Input = CheckPlaceholderExpr(Input.take(), OpLoc);
+ Input = CheckPlaceholderExpr(Input.take());
if (Input.isInvalid()) return ExprError();
return CreateBuiltinUnaryOp(OpLoc, Opc, Input.take());
}
else if (resultType->hasIntegerRepresentation())
break;
else if (resultType->isPlaceholderType()) {
- Input = CheckPlaceholderExpr(Input.take(), OpLoc);
+ Input = CheckPlaceholderExpr(Input.take());
if (Input.isInvalid()) return ExprError();
return CreateBuiltinUnaryOp(OpLoc, Opc, Input.take());
} else {
ScalarTypeToBooleanCastKind(resultType));
}
} else if (resultType->isPlaceholderType()) {
- Input = CheckPlaceholderExpr(Input.take(), OpLoc);
+ Input = CheckPlaceholderExpr(Input.take());
if (Input.isInvalid()) return ExprError();
return CreateBuiltinUnaryOp(OpLoc, Opc, Input.take());
} else {
/// Check for operands with placeholder types and complain if found.
/// Returns true if there was an error and no recovery was possible.
-ExprResult Sema::CheckPlaceholderExpr(Expr *E, SourceLocation Loc) {
+ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
// Placeholder types are always *exactly* the appropriate builtin type.
QualType type = E->getType();