]> granicus.if.org Git - clang/commitdiff
When computing the conversion sequence in overload resolution
authorJohn McCall <rjmccall@apple.com>
Wed, 4 Apr 2012 02:40:27 +0000 (02:40 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 4 Apr 2012 02:40:27 +0000 (02:40 +0000)
for converting an empty list to a scalar, be sure to initialize
the source and destination types so that comparison of conversion
sequences will work in case there are multiple viable candidates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153993 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp [new file with mode: 0644]

index 27b04a74272789e49cf6cef351ed4d46c500aa95..7afa39f3f3b0b099e06ca8312a1f8c43e5e3e6d5 100644 (file)
@@ -4433,6 +4433,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
     else if (NumInits == 0) {
       Result.setStandard();
       Result.Standard.setAsIdentityConversion();
+      Result.Standard.setFromType(ToType);
+      Result.Standard.setAllToTypes(ToType);
     }
     Result.setListInitializationSequence();
     return Result;
diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
new file mode 100644 (file)
index 0000000..ea059ce
--- /dev/null
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// rdar://problem/11120365
+namespace test0 {
+  template <class T> struct A {
+    static void foo(const T &t) {}
+    static void foo(T &&t) {
+      t.foo(); // expected-error {{member reference base type 'int' is not a structure or union}}
+    }
+  }; 
+
+  void test() {
+    A<int>::foo({}); // expected-note {{requested here}}
+  }
+}