[Sema] Check __builtin_bit_cast operand for completeness before materializing it.

This shouldn't be observable, but it doesn't make sense to materialize an
incomplete type.

llvm-svn: 368610
This commit is contained in:
Erik Pilkington 2019-08-12 19:29:43 +00:00
parent 0761a38e8a
commit 055fcec78c

View File

@ -2799,9 +2799,6 @@ void CastOperation::CheckCStyleCast() {
void CastOperation::CheckBuiltinBitCast() {
QualType SrcType = SrcExpr.get()->getType();
if (SrcExpr.get()->isRValue())
SrcExpr = Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
/*IsLValueReference=*/false);
if (Self.RequireCompleteType(OpRange.getBegin(), DestType,
diag::err_typecheck_cast_to_incomplete) ||
@ -2811,6 +2808,10 @@ void CastOperation::CheckBuiltinBitCast() {
return;
}
if (SrcExpr.get()->isRValue())
SrcExpr = Self.CreateMaterializeTemporaryExpr(SrcType, SrcExpr.get(),
/*IsLValueReference=*/false);
CharUnits DestSize = Self.Context.getTypeSizeInChars(DestType);
CharUnits SourceSize = Self.Context.getTypeSizeInChars(SrcType);
if (DestSize != SourceSize) {