brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · fe0af39 Raw
62 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s3 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  struct B { char* x; };22  void bar() {23    fun(&B::x);24    // expected-error@-1 {{no matching function for call to 'fun'}}25    // expected-note@-9  {{candidate template ignored: could not match 'const int' against 'char'}}26  }27}28 29#if __cplusplus > 201402L30namespace noexcept_conversion {31  template<typename R> void foo(R());32  template<typename R> void bar(R()) = delete;33  template<typename R> void bar(R() noexcept) {}34  void f() throw() {35    foo(&f);36    bar(&f);37  }38  // There is no corresponding rule for references.39  // We consider this to be a defect, and allow deduction to succeed in this40  // case. FIXME: Check this should be accepted once the DR is resolved.41  template<typename R> void baz(R(&)());42  void g() {43    baz(f);44  }45 46  // But there is one for member pointers.47  template<typename R, typename C, typename ...A> void quux(R (C::*)(A...));48  struct Q { void f(int, char) noexcept { quux(&Q::f); } };49 50  void g1() noexcept;51  void g2();52  template <class T> int h(T *, T *); // expected-note {{deduced conflicting types for parameter 'T' ('void () noexcept' vs. 'void ()')}}53  int x = h(g1, g2); // expected-error {{no matching function}}54 55  // We consider it a defect that deduction does not support the following.56  // FIXME: Check that the defect is resolved as we expect.57  template<bool B> int i(void () noexcept(B));58  int i1 = i(g1);59  int i2 = i(g2);60}61#endif62