[PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types
Erik Pilkington via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 14 11:19:12 PDT 2016
erik.pilkington updated this revision to Diff 50617.
erik.pilkington added a comment.
Fix the ill-generated diff. Would someone mind taking a look at this?
http://reviews.llvm.org/D17451
Files:
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/conditional-expr.cpp
Index: test/SemaCXX/conditional-expr.cpp
===================================================================
--- test/SemaCXX/conditional-expr.cpp
+++ test/SemaCXX/conditional-expr.cpp
@@ -384,3 +384,12 @@
int &test() { return b_ ? i_ : throw 1; }
};
}
+
+namespace PR26448 {
+struct Base {};
+struct Derived : Base {};
+Base b;
+Derived d;
+typedef decltype(true ? static_cast<Base&&>(b) : static_cast<Derived&&>(d)) x;
+typedef Base &&x;
+}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4672,7 +4672,7 @@
return Result;
}
-/// \brief Try to convert a type to another according to C++0x 5.16p3.
+/// \brief Try to convert a type to another according to C++11 5.16p3.
///
/// This is part of the parameter validation for the ? operator. If either
/// value operand is a class type, the two operands are attempted to be
@@ -4688,17 +4688,21 @@
InitializationKind Kind = InitializationKind::CreateCopy(To->getLocStart(),
SourceLocation());
- // C++0x 5.16p3
+ // C++11 5.16p3
// The process for determining whether an operand expression E1 of type T1
// can be converted to match an operand expression E2 of type T2 is defined
// as follows:
- // -- If E2 is an lvalue:
- bool ToIsLvalue = To->isLValue();
- if (ToIsLvalue) {
- // E1 can be converted to match E2 if E1 can be implicitly converted to
- // type "lvalue reference to T2", subject to the constraint that in the
- // conversion the reference must bind directly to E1.
- QualType T = Self.Context.getLValueReferenceType(ToType);
+ // -- If E2 is an lvalue: E1 can be converted to match E2 if E1 can be
+ // implicitly converted to type "lvalue reference to T2", subject to the
+ // constraint that in the conversion the reference must bind directly to
+ // E1.
+ // -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be
+ // implicitly conveted to the type "rvalue reference to R2", subject to
+ // the constraint that the reference must bind directly.
+ if (To->isLValue() || To->isXValue()) {
+ QualType T = To->isLValue() ? Self.Context.getLValueReferenceType(ToType)
+ : Self.Context.getRValueReferenceType(ToType);
+
InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
InitializationSequence InitSeq(Self, Entity, Kind, From);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17451.50617.patch
Type: text/x-patch
Size: 2545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160314/214f4cfe/attachment.bin>
More information about the cfe-commits
mailing list