From 4ae5b7208ef72dec2a79d3d1c602cb47e9750d69 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 5 Jun 2011 06:15:20 +0000 Subject: [PATCH] Identity and non-identity standard conversion sequences can be compared even when one is a reference binding and the other is not (), 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 --- include/clang/Sema/Overload.h | 3 +-- lib/Sema/SemaOverload.cpp | 10 ++++------ test/SemaCXX/overload-call.cpp | 22 ++++++++++++++++++++++ 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 int &f(const T (&)[N]); + template 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}} + } +} -- 2.40.0