| 1 | // RUN: %clang_cc1 -std=c++1z -verify %s -triple x86_64-unknown-unknown |
| 2 | |
| 3 | struct S; |
| 4 | |
| 5 | typedef void Nothrow() noexcept; |
| 6 | typedef void Throw(); |
| 7 | |
| 8 | Nothrow *a; |
| 9 | Throw *b; |
| 10 | Nothrow S::*c; |
| 11 | Throw S::*d; |
| 12 | |
| 13 | void test() { |
| 14 | a = b; // expected-error {{assigning to 'Nothrow *' (aka 'void (*)() noexcept') from incompatible type 'Throw *' (aka 'void (*)()'): different exception specifications}} |
| 15 | b = a; |
| 16 | c = d; // expected-error {{assigning to 'Nothrow S::*' from incompatible type 'Throw S::*': different exception specifications}} |
| 17 | d = c; |
| 18 | |
| 19 | // Function pointer conversions do not combine properly with qualification conversions. |
| 20 | // FIXME: This seems like a defect. |
| 21 | Nothrow *const *pa = b; // expected-error {{cannot initialize}} |
| 22 | Throw *const *pb = a; // expected-error {{cannot initialize}} |
| 23 | Nothrow *const S::*pc = d; // expected-error {{cannot initialize}} |
| 24 | Throw *const S::*pd = c; // expected-error {{cannot initialize}} |
| 25 | } |
| 26 | |
| 27 | // ... The result is a pointer to the function. |
| 28 | void f() noexcept; |
| 29 | constexpr void (*p)() = &f; |
| 30 | static_assert(f == p); |
| 31 | |
| 32 | struct S { void f() noexcept; }; |
| 33 | constexpr void (S::*q)() = &S::f; |
| 34 | static_assert(q == &S::f); |
| 35 | |
| 36 | |
| 37 | namespace std_example { |
| 38 | void (*p)(); |
| 39 | void (**pp)() noexcept = &p; // expected-error {{cannot initialize a variable of type 'void (**)() noexcept' with an rvalue of type 'void (**)()'}} |
| 40 | |
| 41 | struct S { typedef void (*p)(); operator p(); }; // expected-note {{candidate}} |
| 42 | void (*q)() noexcept = S(); // expected-error {{no viable conversion from 'std_example::S' to 'void (*)() noexcept'}} |
| 43 | } |
| 44 | |