// cast-to-union extension.
if (getType()->isRecordType())
return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+
+ // Integer->integer casts can be handled here, which is important for
+ // things like (int)(&&x-&&y). Scary but true.
+ if (getType()->isIntegerType() &&
+ cast<CastExpr>(this)->getSubExpr()->getType()->isIntegerType())
+ return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+
break;
}
return isEvaluatable(Ctx);
// Explicit and implicit no-op casts
QualType Ty = E->getType(), SubTy = E->getSubExpr()->getType();
if (CGM.getContext().hasSameUnqualifiedType(Ty, SubTy))
- return Visit(E->getSubExpr());
+ return Visit(E->getSubExpr());
+
+ // Handle integer->integer casts for address-of-label differences.
+ if (Ty->isIntegerType() && SubTy->isIntegerType() &&
+ CGF) {
+ llvm::Value *Src = Visit(E->getSubExpr());
+ if (Src == 0) return 0;
+
+ // Use EmitScalarConversion to perform the conversion.
+ return cast<llvm::Constant>(CGF->EmitScalarConversion(Src, SubTy, Ty));
+ }
+
return 0;
}
}