102 lines · cpp
1// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s2 3struct A {4 static constexpr bool x = true;5};6 7namespace N0 {8 9template<typename T, typename U>10void f(T, U) noexcept(T::y); // #111 12template<typename T, typename U> // #213void f(T, U*) noexcept(T::x);14 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.17template<>18void f(A, int*) noexcept;19 20}21 22namespace N1 {23 24template<typename T, typename U>25void f(T, U) noexcept(T::x); // #126 27template<typename T, typename U>28void f(T, U*) noexcept(T::y); // #229// expected-error@-1 {{no member named 'y' in 'A'}}30 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.33template<>34void 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}}37}38 39namespace N2 {40 41template<typename T, typename U>42void f(T, U) noexcept(T::x);43 44template<typename T, typename U>45void f(T, U*) noexcept(T::x);46 47template<typename T, typename U>48void f(T, U**) noexcept(T::y); // expected-error {{no member named 'y' in 'A'}}49 50template<typename T, typename U>51void f(T, U***) noexcept(T::x);52 53template<>54void f(A, int*) noexcept; // expected-note {{previous declaration is here}}55 56template<>57void f(A, int*); // expected-error {{'f<A, int>' is missing exception specification 'noexcept'}}58 59template<>60void 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}}63 64// FIXME: Exception specification is currently set to EST_None if instantiation fails.65template<>66void f(A, int**);67 68template<>69void f(A, int***) noexcept; // expected-note {{previous declaration is here}}70 71template<>72void f(A, int***); // expected-error {{'f<A, int>' is missing exception specification 'noexcept'}}73 74}75 76namespace N3 {77 78template<typename T, typename U>79void f(T, U) noexcept(T::y); // #180 81template<typename T, typename U> // #282void f(T, U*) noexcept(T::x);83 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.86void (*x)(A, int*) = f;87}88 89namespace N4 {90 91template<typename T, typename U>92void f(T, U) noexcept(T::x); // #193 94template<typename T, typename U>95void f(T, U*) noexcept(T::y); // #296// expected-error@-1 {{no member named 'y' in 'A'}}97 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.100void (*x)(A, int*) = f; // expected-note {{in instantiation of exception specification for 'f<A, int>' requested here}}101}102