1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
3 
4 namespace PR8598 {
5   template<class T> struct identity { typedef T type; };
6 
7   template<class T, class C>
f(T C::*,typename identity<T>::type *)8   void f(T C::*, typename identity<T>::type*){}
9 
fPR8598::X10   struct X { void f() {}; };
11 
g()12   void g() { (f)(&X::f, 0); }
13 }
14 
15 namespace PR12132 {
fun(const int * const S::* member)16   template<typename S> void fun(const int* const S::* member) {}
17   struct A { int* x; };
foo()18   void foo() {
19     fun(&A::x);
20   }
21 }
22 
23 #if __cplusplus > 201402L
24 namespace noexcept_conversion {
25   template<typename R> void foo(R());
26   template<typename R> void bar(R()) = delete;
bar(R ()noexcept)27   template<typename R> void bar(R() noexcept) {}
f()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(&)());
g()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...));
fnoexcept_conversion::Q42   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