1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
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.
14 struct A
{ // expected-note {{definition of 'test0::A' is not complete until the closing '}'}}
15 A x
; // expected-error {{field has incomplete type 'A'}}
20 template <class T
> struct A
{
21 A
<int> x
; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}}
26 template <class T
> struct A
;
27 template <> struct A
<int> {};
28 template <class T
> struct A
{
48 void f2() throw(A2
<T
>);
53 void f2() throw(A2
<T
>);
57 template struct A2
<int>;
62 static int (f
)() throw();
63 static int ((((((g
))))() throw(U
)));
64 int (*h
)() noexcept(false);
65 static int (&i
)() noexcept(true);
66 static int (*j
)() throw(U
); // expected-error {{unknown type name 'U'}}
67 static int (k
)() throw(U
);
71 static_assert(noexcept(S::f()), "");
72 static_assert(!noexcept(S::g()), "");
73 static_assert(!noexcept(S().h()), "");
74 static_assert(noexcept(S::i()), "");
79 // FIXME: Maybe suppress the "constructor cannot have a return type" error
80 // if the return type is invalid.
81 nonsense
S() throw (more_nonsense
); // \
82 // expected-error {{'nonsense'}} \
83 // expected-error {{constructor cannot have a return type}}