}
// Operators.
- void VisitCStyleCastExpr(CStyleCastExpr *E);
- void VisitImplicitCastExpr(ImplicitCastExpr *E);
+ void VisitCastExpr(CastExpr *E);
void VisitCallExpr(const CallExpr *E);
void VisitStmtExpr(const StmtExpr *E);
void VisitBinaryOperator(const BinaryOperator *BO);
// Visitor Methods
//===----------------------------------------------------------------------===//
-void AggExprEmitter::VisitCStyleCastExpr(CStyleCastExpr *E) {
- // GCC union extension
- if (E->getSubExpr()->getType()->isScalarType()) {
+void AggExprEmitter::VisitCastExpr(CastExpr *E) {
+ if (E->getCastKind() == CastExpr::CK_ToUnion) {
+ // GCC union extension
QualType PtrTy =
CGF.getContext().getPointerType(E->getSubExpr()->getType());
llvm::Value *CastPtr = Builder.CreateBitCast(DestPtr,
return;
}
- Visit(E->getSubExpr());
-}
-
-void AggExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
+ // FIXME: Remove the CK_Unknown check here.
+ assert((E->getCastKind() == CastExpr::CK_NoOp ||
+ E->getCastKind() == CastExpr::CK_Unknown) &&
+ "Only no-op casts allowed!");
assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(),
E->getType()) &&
"Implicit cast types must be compatible");
// FIXME: Check that the cast destination type is complete.
Diag(TyR.getBegin(), diag::ext_typecheck_cast_nonscalar)
<< castType << castExpr->getSourceRange();
+ Kind = CastExpr::CK_NoOp;
} else if (castType->isUnionType()) {
// GCC cast to union extension
RecordDecl *RD = castType->getAs<RecordType>()->getDecl();
if (Field == FieldEnd)
return Diag(TyR.getBegin(), diag::err_typecheck_cast_to_union_no_type)
<< castExpr->getType() << castExpr->getSourceRange();
+ Kind = CastExpr::CK_ToUnion;
} else {
// Reject any other conversions to non-scalar types.
return Diag(TyR.getBegin(), diag::err_typecheck_cond_expect_scalar)