blob: d3411722283ccad8eac0edae598189f861de7682 [file] [log] [blame]
Richard Smith2e321552014-11-12 02:00:47 +00001// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s -DERRORS
2// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -emit-llvm-only %s
Douglas Gregor049bdca2009-12-08 17:45:32 +00003
Richard Smith2e321552014-11-12 02:00:47 +00004#ifdef ERRORS
Nick Lewycky56412332014-01-11 02:37:12 +00005template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
Douglas Gregor049bdca2009-12-08 17:45:32 +00006struct Incomplete; // expected-note{{forward}}
7
8void test_f1(Incomplete *incomplete_p, int *int_p) {
9 f1(int_p);
Nick Lewycky56412332014-01-11 02:37:12 +000010 f1(incomplete_p); // expected-note{{instantiation of}}
Douglas Gregor049bdca2009-12-08 17:45:32 +000011}
Richard Smith2e321552014-11-12 02:00:47 +000012#endif
13
14template<typename T> void f(void (*p)() throw(T)) {
15#ifdef ERRORS
16 void (*q)() throw(char) = p; // expected-error {{target exception spec}}
17
18 extern void (*p2)() throw(T);
19 void (*q2)() throw(char) = p2; // expected-error {{target exception spec}}
20
21 extern void (*p3)() throw(char);
22 void (*q3)() throw(T) = p3; // expected-error {{target exception spec}}
23
24 void (*q4)() throw(T) = p2; // ok
25#endif
26 p();
27}
28void g() { f<int>(0); } // expected-note {{instantiation of}}