Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / class / class.mem / p2.cpp
blobc63c075574573f330d714e2241b13f657c508c78
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.
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 'A'}}
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}}
25 namespace test2 {
26 template <class T> struct A;
27 template <> struct A<int> {};
28 template <class T> struct A {
29 A<int> x;
33 namespace test3 {
34 struct A {
35 struct B {
36 void f() throw(A);
37 void g() throw(B);
40 void f() throw(A);
41 void g() throw(B);
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);
52 void f1() throw(A2);
53 void f2() throw(A2<T>);
54 void g() throw(B);
57 template struct A2<int>;
60 namespace PR12629 {
61 struct S {
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);
69 struct 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()), "");
77 namespace PR12688 {
78 struct S {
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}}