1 // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
4 static constexpr bool x
= true;
9 template<typename T
, typename U
>
10 void f(T
, U
) noexcept(T::y
); // #1
12 template<typename T
, typename U
> // #2
13 void f(T
, U
*) noexcept(T::x
);
15 // Deduction should succeed for both candidates, and #2 should be selected as the primary template.
16 // Only the exception specification of #2 should be instantiated.
18 void f(A
, int*) noexcept
;
24 template<typename T
, typename U
>
25 void f(T
, U
) noexcept(T::x
); // #1
27 template<typename T
, typename U
>
28 void f(T
, U
*) noexcept(T::y
); // #2
29 // expected-error@-1 {{no member named 'y' in 'A'}}
31 // Deduction should succeed for both candidates, and #2 should be selected as the primary template.
32 // Only the exception specification of #2 should be instantiated.
34 void f(A
, int*) noexcept
; // expected-error {{exception specification in declaration does not match previous declaration}}
35 // expected-note@-1 {{in instantiation of exception specification for 'f<A, int>' requested here}}
36 // expected-note@-2 {{previous declaration is here}}
41 template<typename T
, typename U
>
42 void f(T
, U
) noexcept(T::x
);
44 template<typename T
, typename U
>
45 void f(T
, U
*) noexcept(T::x
);
47 template<typename T
, typename U
>
48 void f(T
, U
**) noexcept(T::y
); // expected-error {{no member named 'y' in 'A'}}
50 template<typename T
, typename U
>
51 void f(T
, U
***) noexcept(T::x
);
54 void f(A
, int*) noexcept
; // expected-note {{previous declaration is here}}
57 void f(A
, int*); // expected-error {{'f<A, int>' is missing exception specification 'noexcept'}}
60 void f(A
, int**) noexcept
; // expected-error {{exception specification in declaration does not match previous declaration}}
61 // expected-note@-1 {{in instantiation of exception specification for 'f<A, int>' requested here}}
62 // expected-note@-2 {{previous declaration is here}}
64 // FIXME: Exception specification is currently set to EST_None if instantiation fails.
69 void f(A
, int***) noexcept
; // expected-note {{previous declaration is here}}
72 void f(A
, int***); // expected-error {{'f<A, int>' is missing exception specification 'noexcept'}}
78 template<typename T
, typename U
>
79 void f(T
, U
) noexcept(T::y
); // #1
81 template<typename T
, typename U
> // #2
82 void f(T
, U
*) noexcept(T::x
);
84 // Deduction should succeed for both candidates, and #2 should be selected by overload resolution.
85 // Only the exception specification of #2 should be instantiated.
86 void (*x
)(A
, int*) = f
;
91 template<typename T
, typename U
>
92 void f(T
, U
) noexcept(T::x
); // #1
94 template<typename T
, typename U
>
95 void f(T
, U
*) noexcept(T::y
); // #2
96 // expected-error@-1 {{no member named 'y' in 'A'}}
98 // Deduction should succeed for both candidates, and #2 should be selected by overload resolution.
99 // Only the exception specification of #2 should be instantiated.
100 void (*x
)(A
, int*) = f
; // expected-note {{in instantiation of exception specification for 'f<A, int>' requested here}}