xref: /aosp_15_r20/external/clang/test/SemaTemplate/instantiate-exception-spec.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS
2*67e74705SXin Li // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s
3*67e74705SXin Li 
4*67e74705SXin Li #ifdef ERRORS
5*67e74705SXin Li template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
6*67e74705SXin Li struct Incomplete; // expected-note{{forward}}
7*67e74705SXin Li 
test_f1(Incomplete * incomplete_p,int * int_p)8*67e74705SXin Li void test_f1(Incomplete *incomplete_p, int *int_p) {
9*67e74705SXin Li   f1(int_p);
10*67e74705SXin Li   f1(incomplete_p); // expected-note{{instantiation of}}
11*67e74705SXin Li }
12*67e74705SXin Li #endif
13*67e74705SXin Li 
f(void (* p)()throw (T))14*67e74705SXin Li template<typename T> void f(void (*p)() throw(T)) {
15*67e74705SXin Li #ifdef ERRORS
16*67e74705SXin Li   void (*q)() throw(char) = p; // expected-error {{target exception spec}}
17*67e74705SXin Li 
18*67e74705SXin Li   extern void (*p2)() throw(T);
19*67e74705SXin Li   void (*q2)() throw(char) = p2; // expected-error {{target exception spec}}
20*67e74705SXin Li 
21*67e74705SXin Li   extern void (*p3)() throw(char);
22*67e74705SXin Li   void (*q3)() throw(T) = p3; // expected-error {{target exception spec}}
23*67e74705SXin Li 
24*67e74705SXin Li   void (*q4)() throw(T) = p2; // ok
25*67e74705SXin Li #endif
26*67e74705SXin Li   p();
27*67e74705SXin Li }
g()28*67e74705SXin Li void g() { f<int>(0); } // expected-note {{instantiation of}}
29