r209060 - More fixes for isBetterOverloadCandidate not being a strict weak ordering. The
Richard Smith
richard-llvm at metafoo.co.uk
Fri May 16 21:36:39 PDT 2014
Author: rsmith
Date: Fri May 16 23:36:39 2014
New Revision: 209060
URL: http://llvm.org/viewvc/llvm-project?rev=209060&view=rev
Log:
More fixes for isBetterOverloadCandidate not being a strict weak ordering. The
bug was obvious from inspection, figuring out a way to test it was... less so.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=209060&r1=209059&r2=209060&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri May 16 23:36:39 2014
@@ -8250,26 +8250,15 @@ isBetterOverloadCandidate(Sema &S,
// other. This only distinguishes the results in non-standard, extension
// cases such as the conversion from a lambda closure type to a function
// pointer or block.
- ImplicitConversionSequence::CompareKind FuncResult
- = compareConversionFunctions(S, Cand1.Function, Cand2.Function);
- if (FuncResult != ImplicitConversionSequence::Indistinguishable)
- return FuncResult;
+ ImplicitConversionSequence::CompareKind Result =
+ compareConversionFunctions(S, Cand1.Function, Cand2.Function);
+ if (Result == ImplicitConversionSequence::Indistinguishable)
+ Result = CompareStandardConversionSequences(S,
+ Cand1.FinalConversion,
+ Cand2.FinalConversion);
- switch (CompareStandardConversionSequences(S,
- Cand1.FinalConversion,
- Cand2.FinalConversion)) {
- case ImplicitConversionSequence::Better:
- // Cand1 has a better conversion sequence.
- return true;
-
- case ImplicitConversionSequence::Worse:
- // Cand1 can't be better than Cand2.
- return false;
-
- case ImplicitConversionSequence::Indistinguishable:
- // Do nothing
- break;
- }
+ if (Result != ImplicitConversionSequence::Indistinguishable)
+ return Result == ImplicitConversionSequence::Better;
// FIXME: Compare kind of reference binding if conversion functions
// convert to a reference type used in direct reference binding, per
Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm?rev=209060&r1=209059&r2=209060&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm (original)
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm Fri May 16 23:36:39 2014
@@ -85,6 +85,24 @@ namespace overloading {
void call_with_lambda() {
int &ir = accept_lambda_conv([](int x) { return x + 1; });
}
+
+ template<typename T> using id = T;
+
+ auto a = [](){};
+ struct C : decltype(a) {
+ using decltype(a)::operator id<void(*)()>;
+ private:
+ using decltype(a)::operator id<void(^)()>;
+ } extern c;
+
+ struct D : decltype(a) {
+ using decltype(a)::operator id<void(^)()>;
+ private:
+ using decltype(a)::operator id<void(*)()>; // expected-note {{here}}
+ } extern d;
+
+ bool r1 = c;
+ bool r2 = d; // expected-error {{private}}
}
namespace PR13117 {
More information about the cfe-commits
mailing list