Clang Project

clang_source_code/test/SemaCXX/zero-length-arrays.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
4
5// <rdar://problem/10228639>
6class Foo {
7  ~Foo();
8  Foo(const Foo&);
9public:
10  Foo(int);
11};
12
13class Bar {
14  int foo_count;
15  Foo foos[0];
16#if __cplusplus >= 201103L
17// expected-note@-2 {{copy constructor of 'Bar' is implicitly deleted because field 'foos' has an inaccessible copy constructor}}
18#endif
19  Foo foos2[0][2];
20  Foo foos3[2][0];
21
22public:
23  Bar(): foo_count(0) { }    
24  ~Bar() { }
25};
26
27void testBar() {
28  Bar b;
29  Bar b2(b);
30#if __cplusplus >= 201103L
31// expected-error@-2 {{call to implicitly-deleted copy constructor of 'Bar}}
32#else
33// expected-no-diagnostics
34#endif
35  b = b2;
36}
37