Clang Project

clang_source_code/test/CXX/except/except.spec/p2-dynamic-types.cpp
1// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
2
3// Dynamic specifications: valid types.
4
5struct Incomplete; // expected-note 3 {{forward declaration}}
6
7// Exception spec must not have incomplete types, or pointers to them, except
8// void.
9void ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}}
10void ic2() throw(Incomplete); // expected-error {{incomplete type 'Incomplete' is not allowed in exception specification}}
11void ic3() throw(void*);
12void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'Incomplete' is not allowed in exception specification}}
13void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'Incomplete' is not allowed in exception specification}}
14
15// Don't suppress errors in template instantiation.
16template <typename T> struct TEx; // expected-note {{template is declared here}}
17
18void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
19
20// DR 437, class throws itself.
21struct DR437 {
22   void f() throw(DR437);
23   void g() throw(DR437*);
24   void h() throw(DR437&);
25};
26
27// DR 437 within a nested class
28struct DR437_out {
29   struct DR437_in {
30      void f() throw(DR437_out);
31      void g() throw(DR437_out*);
32      void h() throw(DR437_out&);
33   }; 
34};
35