Clang Project

clang_source_code/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
3
4namespace PR8598 {
5  template<class T> struct identity { typedef T type; };
6
7  template<class T, class C>
8  void f(T C::*, typename identity<T>::type*){}
9  
10  struct X { void f() {}; };
11  
12  void g() { (f)(&X::f, 0); }
13}
14
15namespace PR12132 {
16  template<typename S> void fun(const int* const S::* member) {}
17  struct A { int* x; };
18  void foo() {
19    fun(&A::x);
20  }
21}
22
23#if __cplusplus > 201402L
24namespace noexcept_conversion {
25  template<typename R> void foo(R());
26  template<typename R> void bar(R()) = delete;
27  template<typename R> void bar(R() noexcept) {}
28  void f() throw() {
29    foo(&f);
30    bar(&f);
31  }
32  // There is no corresponding rule for references.
33  // We consider this to be a defect, and allow deduction to succeed in this
34  // case. FIXME: Check this should be accepted once the DR is resolved.
35  template<typename R> void baz(R(&)());
36  void g() {
37    baz(f);
38  }
39
40  // But there is one for member pointers.
41  template<typename R, typename C, typename ...A> void quux(R (C::*)(A...));
42  struct Q { void f(int, char) noexcept { quux(&Q::f); } };
43
44  void g1() noexcept;
45  void g2();
46  template <class T> int h(T *, T *); // expected-note {{deduced conflicting types for parameter 'T' ('void () noexcept' vs. 'void ()')}}
47  int x = h(g1, g2); // expected-error {{no matching function}}
48
49  // We consider it a defect that deduction does not support the following.
50  // FIXME: Check that the defect is resolved as we expect.
51  template<bool B> int i(void () noexcept(B));
52  int i1 = i(g1);
53  int i2 = i(g2);
54}
55#else
56// expected-no-diagnostics
57#endif
58