summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-09-03 00:28:25 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-09-03 00:28:25 +0000
commit6098fd1989f6b12ff7b0c45a276c4341d3ee9b2a (patch)
tree585cbe0e3ee5ba8310f93d348144a9db3d983a83 /clang/lib/Sema/SemaOverload.cpp
parent4efaa30934e8143cab9c47563ef49678aa9f635a (diff)
downloadbcm5719-llvm-6098fd1989f6b12ff7b0c45a276c4341d3ee9b2a.tar.gz
bcm5719-llvm-6098fd1989f6b12ff7b0c45a276c4341d3ee9b2a.zip
[Sema] Fix how we set implicit conversion kinds.
We have invariants we like to guarantee for the `ImplicitConversionKind`s in a `StandardConversionSequence`. These weren't being upheld in code that r280553 touched, so Richard suggested that we should fix that. See D24113. I'm not entirely sure how to go about testing this, so no test case is included. Suggestions welcome. llvm-svn: 280562
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 38144a94a14..37552b57d66 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1790,10 +1790,10 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
/*Diagnose=*/false,
/*DiagnoseCFAudited=*/false,
/*ConvertRHS=*/false);
- ImplicitConversionKind ImplicitConv;
+ ImplicitConversionKind SecondConv;
switch (Conv) {
case Sema::Compatible:
- ImplicitConv = ICK_C_Only_Conversion;
+ SecondConv = ICK_C_Only_Conversion;
break;
// For our purposes, discarding qualifiers is just as bad as using an
// incompatible pointer. Note that an IncompatiblePointer conversion can drop
@@ -1801,18 +1801,24 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
case Sema::CompatiblePointerDiscardsQualifiers:
case Sema::IncompatiblePointer:
case Sema::IncompatiblePointerSign:
- ImplicitConv = ICK_Incompatible_Pointer_Conversion;
+ SecondConv = ICK_Incompatible_Pointer_Conversion;
break;
default:
return false;
}
- SCS.setAllToTypes(ToType);
- // We need to set all three because we want this conversion to rank terribly,
- // and we don't know what conversions it may overlap with.
- SCS.First = ImplicitConv;
- SCS.Second = ImplicitConv;
- SCS.Third = ImplicitConv;
+ // First can only be an lvalue conversion, so we pretend that this was the
+ // second conversion. First should already be valid from earlier in the
+ // function.
+ SCS.Second = SecondConv;
+ SCS.setToType(1, ToType);
+
+ // Third is Identity, because Second should rank us worse than any other
+ // conversion. This could also be ICK_Qualification, but it's simpler to just
+ // lump everything in with the second conversion, and we don't gain anything
+ // from making this ICK_Qualification.
+ SCS.Third = ICK_Identity;
+ SCS.setToType(2, ToType);
return true;
}
OpenPOWER on IntegriCloud