[clang] 065fc1e - PR45521: Preserve the value kind when performing a standard conversion
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 18:28:40 PDT 2020
Author: Richard Smith
Date: 2020-07-07T18:28:28-07:00
New Revision: 065fc1eafe7c6f67f8029bcd38e6864b3c429e35
URL: https://github.com/llvm/llvm-project/commit/065fc1eafe7c6f67f8029bcd38e6864b3c429e35
DIFF: https://github.com/llvm/llvm-project/commit/065fc1eafe7c6f67f8029bcd38e6864b3c429e35.diff
LOG: 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.
Added:
Modified:
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/references.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 0a0bb3952cd8..d885920b6c14 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4203,8 +4203,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:
@@ -4441,11 +4441,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() &&
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d68be854aeeb..599e81d1b4d0 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4709,7 +4709,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);
diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp
index f30e16d990eb..eaab1ae833e4 100644
--- a/clang/test/SemaCXX/references.cpp
+++ b/clang/test/SemaCXX/references.cpp
@@ -201,3 +201,9 @@ namespace RefCollapseTypePrinting {
template void add_rref<const int&>(); // expected-note {{instantiation of}}
template void add_rref<const int&&>(); // expected-note {{instantiation of}}
}
+
+namespace PR45521 {
+ struct a { template<class b> a(const b * const&); };
+ int *d;
+ const a &r = d;
+}
More information about the cfe-commits
mailing list