Merge commit 065fc1eafe7c from llvm git (by Richard Smith):

PR45521: Preserve the value kind when performing a standard
  conversion sequence on a glvalue expression.

  If the sequence is supposed to perform an lvalue-to-rvalue
  conversion, then one will be specified as the first conversion in the
  sequence. Otherwise, one should not be invented.

This should fix clang crashing with "can't implicitly cast lvalue to
rvalue with this cast kind", followed by "UNREACHABLE executed at
/usr/src/contrib/llvm-project/clang/lib/Sema/Sema.cpp:538!", when
building recent versions of Ceph, and the CPAN module SYBER/Date-5.2.0.

Reported by:	Willem Jan Withagen <wjw@digiware.nl>, eserte12@yahoo.de
PR:		245530, 247812
MFC after:	3 days
This commit is contained in:
dim 2020-07-08 16:50:47 +00:00
parent 25dc1f8711
commit bf4c102a45
2 changed files with 4 additions and 8 deletions

View File

@ -4063,8 +4063,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
break;
case ICK_Compatible_Conversion:
From = ImpCastExprToType(From, ToType, CK_NoOp,
VK_RValue, /*BasePath=*/nullptr, CCK).get();
From = ImpCastExprToType(From, ToType, CK_NoOp, From->getValueKind(),
/*BasePath=*/nullptr, CCK).get();
break;
case ICK_Writeback_Conversion:
@ -4303,11 +4303,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
break;
case ICK_Qualification: {
// The qualification keeps the category of the inner expression, unless the
// target type isn't a reference.
ExprValueKind VK =
ToType->isReferenceType() ? From->getValueKind() : VK_RValue;
ExprValueKind VK = From->getValueKind();
CastKind CK = CK_NoOp;
if (ToType->isReferenceType() &&

View File

@ -4693,7 +4693,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
Sema::ReferenceConversions::NestedQualification)
? ICK_Qualification
: ICK_Identity;
ICS.Standard.FromTypePtr = T2.getAsOpaquePtr();
ICS.Standard.setFromType(T2);
ICS.Standard.setToType(0, T2);
ICS.Standard.setToType(1, T1);
ICS.Standard.setToType(2, T1);