diff options
author | Erik Pilkington <erik.pilkington@gmail.com> | 2019-08-12 19:29:43 +0000 |
---|---|---|
committer | Erik Pilkington <erik.pilkington@gmail.com> | 2019-08-12 19:29:43 +0000 |
commit | 055fcec78cf6026719af4966c7568e39c1229d2d (patch) | |
tree | 61b63147257e4764dbd17003125e42a6bb8172ec /clang/lib/Sema/SemaCast.cpp | |
parent | 0761a38e8af5bddaf8d7622501c56988bea86af3 (diff) | |
download | bcm5719-llvm-055fcec78cf6026719af4966c7568e39c1229d2d.tar.gz bcm5719-llvm-055fcec78cf6026719af4966c7568e39c1229d2d.zip |
[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
Diffstat (limited to 'clang/lib/Sema/SemaCast.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 7a1d52ad4ea..71e5e8e4286 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -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) { |