aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-23 18:59:35 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-23 18:59:35 +0000
commitbf6e3179eaf66b3eca43cbdbd09b71db40fa85fc (patch)
tree7aa644a5dfa683f80415ea6ec13e6b08f2799f3e /lib/Sema/SemaOverload.cpp
parent2d3ba4f5a923a90c3fc290ddfba5e36c2d0a9b46 (diff)
Tests for explicit conversion operators, along with a fix to avoid
considering explicit conversion operators when determining surrogate functions. Fixes PR10453. Note that there are a few test cases where Clang is still wrong because it does not implement DR899; see PR10456. Patch by Jonathan Sauer! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135857 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index c4586fbfd8..93acf89e90 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -9384,8 +9384,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
}
// C++ [over.call.object]p2:
- // In addition, for each conversion function declared in T of the
- // form
+ // In addition, for each (non-explicit in C++0x) conversion function
+ // declared in T of the form
//
// operator conversion-type-id () cv-qualifier;
//
@@ -9415,16 +9415,19 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
continue;
CXXConversionDecl *Conv = cast<CXXConversionDecl>(D);
-
- // Strip the reference type (if any) and then the pointer type (if
- // any) to get down to what might be a function type.
- QualType ConvType = Conv->getConversionType().getNonReferenceType();
- if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
- ConvType = ConvPtrType->getPointeeType();
-
- if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
- AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
- Object.get(), Args, NumArgs, CandidateSet);
+ if (!Conv->isExplicit()) {
+ // Strip the reference type (if any) and then the pointer type (if
+ // any) to get down to what might be a function type.
+ QualType ConvType = Conv->getConversionType().getNonReferenceType();
+ if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
+ ConvType = ConvPtrType->getPointeeType();
+
+ if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
+ {
+ AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
+ Object.get(), Args, NumArgs, CandidateSet);
+ }
+ }
}
// Perform overload resolution.