summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp3
-rw-r--r--clang/lib/Sema/SemaInit.cpp16
-rw-r--r--clang/test/CXX/expr/expr.cond/p4.cpp10
3 files changed, 16 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 5c3900adbde..23e649b6139 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5199,8 +5199,7 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To,
//
// This actually refers very narrowly to the lvalue-to-rvalue conversion, not
// to the array-to-pointer or function-to-pointer conversions.
- if (!TTy->getAs<TagType>())
- TTy = TTy.getUnqualifiedType();
+ TTy = TTy.getNonLValueExprType(Self.Context);
InitializedEntity Entity = InitializedEntity::InitializeTemporary(TTy);
InitializationSequence InitSeq(Self, Entity, Kind, From);
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ce012896f5b..515a6676d40 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3609,17 +3609,7 @@ static void TryConstructorInitialization(Sema &S,
UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isRValue() &&
S.Context.hasSameUnqualifiedType(UnwrappedArgs[0]->getType(), DestType)) {
// Convert qualifications if necessary.
- QualType InitType = UnwrappedArgs[0]->getType();
- ImplicitConversionSequence ICS;
- ICS.setStandard();
- ICS.Standard.setAsIdentityConversion();
- ICS.Standard.setFromType(InitType);
- ICS.Standard.setAllToTypes(InitType);
- if (!S.Context.hasSameType(InitType, DestType)) {
- ICS.Standard.Third = ICK_Qualification;
- ICS.Standard.setToType(2, DestType);
- }
- Sequence.AddConversionSequenceStep(ICS, DestType);
+ Sequence.AddQualificationConversionStep(DestType, VK_RValue);
if (ILE)
Sequence.RewrapReferenceInitList(DestType, ILE);
return;
@@ -4790,6 +4780,8 @@ static void TryUserDefinedConversion(Sema &S,
// FIXME: Mark this copy as extraneous.
if (!S.getLangOpts().CPlusPlus1z)
Sequence.AddFinalCopy(DestType);
+ else if (DestType.hasQualifiers())
+ Sequence.AddQualificationConversionStep(DestType, VK_RValue);
return;
}
@@ -4812,6 +4804,8 @@ static void TryUserDefinedConversion(Sema &S,
Function->getReturnType()->isReferenceType() ||
!S.Context.hasSameUnqualifiedType(ConvType, DestType))
Sequence.AddFinalCopy(DestType);
+ else if (!S.Context.hasSameType(ConvType, DestType))
+ Sequence.AddQualificationConversionStep(DestType, VK_RValue);
return;
}
diff --git a/clang/test/CXX/expr/expr.cond/p4.cpp b/clang/test/CXX/expr/expr.cond/p4.cpp
new file mode 100644
index 00000000000..4d0cf3538cf
--- /dev/null
+++ b/clang/test/CXX/expr/expr.cond/p4.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++98 -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s
+
+// expected-no-diagnostics
+
+struct A { A(); A(int); };
+void f() {
+ const A a;
+ true ? a : 0;
+}
OpenPOWER on IntegriCloud