xref: /llvm-project/clang/test/SemaCXX/zero-length-arrays.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
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 class Foo {
6   ~Foo();
7   Foo(const Foo&);
8 public:
9   Foo(int);
10 };
11 
12 class Bar {
13   int foo_count;
14   Foo foos[0];
15 #if __cplusplus >= 201103L
16 // expected-note@-2 {{copy constructor of 'Bar' is implicitly deleted because field 'foos' has an inaccessible copy constructor}}
17 #endif
18   Foo foos2[0][2];
19   Foo foos3[2][0];
20 
21 public:
Bar()22   Bar(): foo_count(0) { }
~Bar()23   ~Bar() { }
24 };
25 
testBar()26 void testBar() {
27   Bar b;
28   Bar b2(b);
29 #if __cplusplus >= 201103L
30 // expected-error@-2 {{call to implicitly-deleted copy constructor of 'Bar}}
31 #else
32 // expected-no-diagnostics
33 #endif
34   b = b2;
35 }
36