Home | History | Annotate | Download | only in class.mem
      1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
      2 
      3 // C++11 [class.mem]p2:
      4 //   A class is considered a completely-defined object type (or
      5 //   complete type) at the closing } of the class-specifier. Within
      6 //   the class member-specification, the class is regarded as complete
      7 //   within function bodies, default arguments,
      8 //   exception-specifications, and brace-or-equal-initializers for
      9 //   non-static data members (including such things in nested classes).
     10 //   Otherwise it is regarded as incomplete within its own class
     11 //   member-specification.
     12 
     13 namespace test0 {
     14   struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}}
     15     A x; // expected-error {{field has incomplete type 'test0::A'}}
     16   };
     17 }
     18 
     19 namespace test1 {
     20   template <class T> struct A {
     21     A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}}
     22   };
     23 }
     24 
     25 namespace test2 {
     26   template <class T> struct A;
     27   template <> struct A<int> {};
     28   template <class T> struct A {
     29     A<int> x;
     30   };
     31 }
     32 
     33 namespace test3 {
     34   struct A {
     35     struct B {
     36       void f() throw(A);
     37       void g() throw(B);
     38     };
     39 
     40     void f() throw(A);
     41     void g() throw(B);
     42   };
     43 
     44   template<typename T>
     45   struct A2 {
     46     struct B {
     47       void f1() throw(A2);
     48       void f2() throw(A2<T>);
     49       void g() throw(B);
     50     };
     51 
     52     void f1() throw(A2);
     53     void f2() throw(A2<T>);
     54     void g() throw(B);
     55   };
     56 
     57   template struct A2<int>;
     58 }
     59