instantiate-exception-spec.cpp 944 B

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