a.makarov created this revision.
a.makarov added a reviewer: rsmith.
a.makarov added a subscriber: cfe-commits.

It's a patch for PR28050. Seems like overloading resolution wipes out the first 
standard conversion sequence (before user-defined conversion) in case of 
deprecated string literal conversion.

http://reviews.llvm.org/D21228

Files:
  include/clang/Sema/Overload.h
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/pr28050.cpp

Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1199,7 +1199,6 @@
   case OR_Success:
   case OR_Deleted:
     ICS.setUserDefined();
-    ICS.UserDefined.Before.setAsIdentityConversion();
     // C++ [over.ics.user]p4:
     //   A conversion of an expression of class type to the same class
     //   type is given Exact Match rank, and a conversion of an
@@ -4540,7 +4539,6 @@
       return ICS;
     }
 
-    ICS.UserDefined.Before.setAsIdentityConversion();
     ICS.UserDefined.After.ReferenceBinding = true;
     ICS.UserDefined.After.IsLvalueReference = !isRValRef;
     ICS.UserDefined.After.BindsToFunctionLvalue = false;
Index: include/clang/Sema/Overload.h
===================================================================
--- include/clang/Sema/Overload.h
+++ include/clang/Sema/Overload.h
@@ -428,8 +428,11 @@
     };
 
     ImplicitConversionSequence()
-      : ConversionKind(Uninitialized), StdInitializerListElement(false)
-    {}
+        : ConversionKind(Uninitialized), StdInitializerListElement(false) {
+      Standard.First = ICK_Identity;
+      Standard.Second = ICK_Identity;
+      Standard.Third = ICK_Identity;
+    }
     ~ImplicitConversionSequence() {
       destruct();
     }
Index: test/SemaCXX/pr28050.cpp
===================================================================
--- test/SemaCXX/pr28050.cpp
+++ test/SemaCXX/pr28050.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++11 %s -fsyntax-only
+//
+// expected-no-diagnostics
+
+class A {
+public:
+  A(char *s) {}
+  A(A &&) = delete;
+};
+
+int main() { A a("OK"); }


Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1199,7 +1199,6 @@
   case OR_Success:
   case OR_Deleted:
     ICS.setUserDefined();
-    ICS.UserDefined.Before.setAsIdentityConversion();
     // C++ [over.ics.user]p4:
     //   A conversion of an expression of class type to the same class
     //   type is given Exact Match rank, and a conversion of an
@@ -4540,7 +4539,6 @@
       return ICS;
     }
 
-    ICS.UserDefined.Before.setAsIdentityConversion();
     ICS.UserDefined.After.ReferenceBinding = true;
     ICS.UserDefined.After.IsLvalueReference = !isRValRef;
     ICS.UserDefined.After.BindsToFunctionLvalue = false;
Index: include/clang/Sema/Overload.h
===================================================================
--- include/clang/Sema/Overload.h
+++ include/clang/Sema/Overload.h
@@ -428,8 +428,11 @@
     };
 
     ImplicitConversionSequence()
-      : ConversionKind(Uninitialized), StdInitializerListElement(false)
-    {}
+        : ConversionKind(Uninitialized), StdInitializerListElement(false) {
+      Standard.First = ICK_Identity;
+      Standard.Second = ICK_Identity;
+      Standard.Third = ICK_Identity;
+    }
     ~ImplicitConversionSequence() {
       destruct();
     }
Index: test/SemaCXX/pr28050.cpp
===================================================================
--- test/SemaCXX/pr28050.cpp
+++ test/SemaCXX/pr28050.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++11 %s -fsyntax-only
+//
+// expected-no-diagnostics
+
+class A {
+public:
+  A(char *s) {}
+  A(A &&) = delete;
+};
+
+int main() { A a("OK"); }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to