p2.cpp revision d46a1125d43bcfd47fbd1206ebd1226863549390
1// RUN: %clang_cc1 -fsyntax-only -verify %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 13namespace 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 19namespace 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 25namespace 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