aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-06-05 06:15:20 +0000
committerDouglas Gregor <dgregor@apple.com>2011-06-05 06:15:20 +0000
commit4ae5b7208ef72dec2a79d3d1c602cb47e9750d69 (patch)
tree41ed246681ce059b4f57b51658cc77681db74109
parent63f62df485de57c6b0db167d96bb0f92562adb7b (diff)
Identity and non-identity standard conversion sequences can be
compared even when one is a reference binding and the other is not (<rdar://problem/9173984>), but the definition of an identity sequence does not involve lvalue-to-rvalue adjustments (PR9507). Fix both inter-related issues. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132660 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Sema/Overload.h3
-rw-r--r--lib/Sema/SemaOverload.cpp10
-rw-r--r--test/SemaCXX/overload-call.cpp22
3 files changed, 27 insertions, 8 deletions
diff --git a/include/clang/Sema/Overload.h b/include/clang/Sema/Overload.h
index e196e83a0e..55931f2318 100644
--- a/include/clang/Sema/Overload.h
+++ b/include/clang/Sema/Overload.h
@@ -202,8 +202,7 @@ namespace clang {
void setAsIdentityConversion();
bool isIdentityConversion() const {
- return First == ICK_Identity && Second == ICK_Identity &&
- Third == ICK_Identity;
+ return Second == ICK_Identity && Third == ICK_Identity;
}
ImplicitConversionRank getRank() const;
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index e43c5fbbb5..eb1400cd57 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2523,12 +2523,10 @@ compareStandardConversionSubsets(ASTContext &Context,
// the identity conversion sequence is considered to be a subsequence of
// any non-identity conversion sequence
- if (SCS1.ReferenceBinding == SCS2.ReferenceBinding) {
- if (SCS1.isIdentityConversion() && !SCS2.isIdentityConversion())
- return ImplicitConversionSequence::Better;
- else if (!SCS1.isIdentityConversion() && SCS2.isIdentityConversion())
- return ImplicitConversionSequence::Worse;
- }
+ if (SCS1.isIdentityConversion() && !SCS2.isIdentityConversion())
+ return ImplicitConversionSequence::Better;
+ else if (!SCS1.isIdentityConversion() && SCS2.isIdentityConversion())
+ return ImplicitConversionSequence::Worse;
if (SCS1.Second != SCS2.Second) {
if (SCS1.Second == ICK_Identity)
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 81a88a3a9a..9cc48993fd 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -503,3 +503,25 @@ namespace rdar8499524 {
g(W());
}
}
+
+namespace rdar9173984 {
+ template <typename T, unsigned long N> int &f(const T (&)[N]);
+ template <typename T> float &f(const T *);
+
+ void test() {
+ int arr[2] = {0, 0};
+ int *arrp = arr;
+ int &ir = f(arr);
+ float &fr = f(arrp);
+ }
+}
+
+namespace PR9507 {
+ void f(int * const&); // expected-note{{candidate function}}
+ void f(int const(&)[1]); // expected-note{{candidate function}}
+
+ int main() {
+ int n[1];
+ f(n); // expected-error{{call to 'f' is ambiguous}}
+ }
+}