160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// Dynamic specifications: valid types.
460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlstruct Incomplete; // expected-note 3 {{forward declaration}}
660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// Exception spec must not have incomplete types, or pointers to them, except
860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// void.
960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}}
1060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid ic2() throw(Incomplete); // expected-error {{incomplete type 'Incomplete' is not allowed in exception specification}}
1160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid ic3() throw(void*);
1260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'Incomplete' is not allowed in exception specification}}
1360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'Incomplete' is not allowed in exception specification}}
1460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
1560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// Don't suppress errors in template instantiation.
1660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redltemplate <typename T> struct TEx; // expected-note {{template is declared here}}
1760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
1860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlvoid tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
1960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
2060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// DR 437, class throws itself.
2160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlstruct DR437 {
2260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl   void f() throw(DR437);
2360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl   void g() throw(DR437*);
2460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl   void h() throw(DR437&);
2560618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl};
2660618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl
2760618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl// DR 437 within a nested class
2860618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redlstruct DR437_out {
2960618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl   struct DR437_in {
3060618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl      void f() throw(DR437_out);
3160618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl      void g() throw(DR437_out*);
3260618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl      void h() throw(DR437_out&);
3360618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl   };
3460618fa7f88d5162bb5b40988b6b38d4d75d6fc6Sebastian Redl};
35