p2.cpp revision 74e2fc332e07c76d4e69ccbd0e9e47a0bafd3908
19a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// RUN: %clang_cc1 -fsyntax-only -verify %s 29a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 39a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// C++11 [class.mem]p2: 49a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// A class is considered a completely-defined object type (or 59a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// complete type) at the closing } of the class-specifier. Within 69a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// the class member-specification, the class is regarded as complete 79a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// within function bodies, default arguments, 89a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// exception-specifications, and brace-or-equal-initializers for 99a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// non-static data members (including such things in nested classes). 109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org// Otherwise it is regarded as incomplete within its own class 11e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org// member-specification. 12e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org 139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace test0 { 149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}} 159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org A x; // expected-error {{field has incomplete type 'test0::A'}} 16774b3d38a4a0f1a8ec08972a3c543cb5d607ce13henrike@webrtc.org }; 17e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org} 189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace test1 { 209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org template <class T> struct A { 219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}} 229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} 249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace test2 { 269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org template <class T> struct A; 279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org template <> struct A<int> {}; 289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org template <class T> struct A { 299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org A<int> x; 309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} 329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace test3 { 349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org struct A { 359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org struct B { 369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f() throw(A); 379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void g() throw(B); 389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 39c1caa69f05663fc729af5a921eb95a73709f7dcdturaj@webrtc.org 409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f() throw(A); 419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void g() throw(B); 429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 44c1caa69f05663fc729af5a921eb95a73709f7dcdturaj@webrtc.org template<typename T> 45c1caa69f05663fc729af5a921eb95a73709f7dcdturaj@webrtc.org struct A2 { 469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org struct B { 479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f1() throw(A2); 489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f2() throw(A2<T>); 499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void g() throw(B); 509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f1() throw(A2); 539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void f2() throw(A2<T>); 549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org void g() throw(B); 559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org }; 569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org 579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org template struct A2<int>; 589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org} 599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org