summaryrefslogtreecommitdiff
path: root/clang/test/CXX/over/over.match
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/over/over.match')
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp15
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp14
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp59
-rw-r--r--clang/test/CXX/over/over.match/over.match.best/p1.cpp16
-rw-r--r--clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp37
-rw-r--r--clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp70
6 files changed, 211 insertions, 0 deletions
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
new file mode 100644
index 0000000..ea059ce
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
@@ -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}}
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp
new file mode 100644
index 0000000..1c71468
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+namespace PR6285 {
+ template<typename T> struct identity
+ { typedef T type; };
+
+ struct D {
+ template<typename T = short>
+ operator typename identity<T>::type(); // expected-note{{candidate}}
+ };
+
+ int f() { return D(); } // expected-error{{no viable conversion}}
+}
+
diff --git a/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp b/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
new file mode 100644
index 0000000..3971acc
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+namespace std_example {
+ int i;
+ int f1();
+ int&& f2();
+ int &g(const int &);
+ float &g(const int &&);
+ int &j = g(i);
+ float &k = g(f1());
+ float &l = g(f2());
+
+ int &g2(const int &);
+ float &g2(int &&);
+ int &j2 = g2(i);
+ float &k2 = g2(f1());
+ float &l2 = g2(f2());
+
+ // FIXME: We don't support ref-qualifiers yet.
+#if 0
+ struct A {
+ A& operator<<(int);
+ void p() &;
+ void p() &&;
+ };
+
+ A& operator<<(A&&, char);
+ A() << 1;
+ A() << 'c';
+ A a;
+ a << 1;
+ a << 'c';
+ A().p();
+ a.p();
+#endif
+}
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&&> {
+ typedef T type;
+};
+
+namespace FunctionReferencesOverloading {
+ template<typename T> int &f(typename remove_reference<T>::type&);
+ template<typename T> float &f(typename remove_reference<T>::type&&);
+
+ void test_f(int (&func_ref)(int)) {
+ int &ir = f<int (&)(int)>(func_ref);
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.best/p1.cpp b/clang/test/CXX/over/over.match/over.match.best/p1.cpp
new file mode 100644
index 0000000..5c315a7
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.best/p1.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T> int &f0(T*, int);
+float &f0(void*, int);
+
+void test_f0(int* ip, void *vp) {
+ // One argument is better...
+ int &ir = f0(ip, 0);
+
+ // Prefer non-templates to templates
+ float &fr = f0(vp, 0);
+}
+
+// Partial ordering of function template specializations will be tested
+// elsewhere
+// FIXME: Initialization by user-defined conversion is tested elsewhere
diff --git a/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp b/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
new file mode 100644
index 0000000..31a679f
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+
+namespace ExplicitConv {
+ struct X { }; // expected-note 2{{candidate constructor}}
+
+ struct Y {
+ explicit operator X() const;
+ };
+
+ void test(const Y& y) {
+ X x(static_cast<X>(y));
+ X x2((X)y);
+ X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}}
+ }
+}
+
+namespace DR899 {
+ struct C { }; // expected-note 2 {{candidate constructor}}
+
+ struct A {
+ explicit operator int() const;
+ explicit operator C() const;
+ };
+
+ struct B {
+ int i;
+ B(const A& a): i(a) { }
+ };
+
+ int main() {
+ A a;
+ int i = a; // expected-error{{no viable conversion}}
+ int j(a);
+ C c = a; // expected-error{{no viable conversion}}
+ C c2(a);
+ }
+}
diff --git a/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp b/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
new file mode 100644
index 0000000..3845af0
--- /dev/null
+++ b/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<typename T> T &lvalue();
+template<typename T> T &&xvalue();
+template<typename T> T prvalue();
+
+struct X0 {
+ int &f() &;
+ float &f() &&;
+
+ template<typename T> int &ft(T) &;
+ template<typename T> float &ft(T) &&;
+
+ typedef int &(*func_int_ref)();
+ typedef float &(*func_float_ref)();
+
+ operator func_int_ref() &;
+ operator func_float_ref() &&;
+
+ void g();
+
+ int &operator+(const X0&) &;
+ float &operator+(const X0&) &&;
+
+ template<typename T> int &operator+(const T&) &;
+ template<typename T> float &operator+(const T&) &&;
+
+ int &h() const&;
+ float &h() &&;
+ int &h2() const&;
+ float &h2() const&&;
+};
+
+void X0::g() {
+ int &ir1 = f();
+ int &ir2 = X0::f();
+}
+
+void test_ref_qualifier_binding() {
+ int &ir1 = lvalue<X0>().f();
+ float &fr1 = xvalue<X0>().f();
+ float &fr2 = prvalue<X0>().f();
+ int &ir2 = lvalue<X0>().ft(1);
+ float &fr3 = xvalue<X0>().ft(2);
+ float &fr4 = prvalue<X0>().ft(3);
+}
+
+void test_ref_qualifier_binding_with_surrogates() {
+ int &ir1 = lvalue<X0>()();
+ float &fr1 = xvalue<X0>()();
+ float &fr2 = prvalue<X0>()();
+}
+
+void test_ref_qualifier_binding_operators() {
+ int &ir1 = lvalue<X0>() + prvalue<X0>();
+ float &fr1 = xvalue<X0>() + prvalue<X0>();
+ float &fr2 = prvalue<X0>() + prvalue<X0>();
+ int &ir2 = lvalue<X0>() + 1;
+ float &fr3 = xvalue<X0>() + 2;
+ float &fr4 = prvalue<X0>() + 3;
+}
+
+void test_ref_qualifier_overloading() {
+ int &ir1 = lvalue<X0>().h();
+ float &fr1 = xvalue<X0>().h();
+ float &fr2 = prvalue<X0>().h();
+ int &ir2 = lvalue<X0>().h2();
+ float &fr3 = xvalue<X0>().h2();
+ float &fr4 = prvalue<X0>().h2();
+}