xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/c99-variable-length-array-cxx11.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wvla-extension %s
2*f4a2713aSLionel Sambuc struct StillPOD {
3*f4a2713aSLionel Sambuc   StillPOD() = default;
4*f4a2713aSLionel Sambuc };
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc struct StillPOD2 {
7*f4a2713aSLionel Sambuc   StillPOD np;
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc struct NonPOD {
NonPODNonPOD11*f4a2713aSLionel Sambuc   NonPOD(int) {}
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc struct POD {
15*f4a2713aSLionel Sambuc   int x;
16*f4a2713aSLionel Sambuc   int y;
17*f4a2713aSLionel Sambuc };
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc // We allow VLAs of POD types, only.
vla(int N)20*f4a2713aSLionel Sambuc void vla(int N) {
21*f4a2713aSLionel Sambuc   int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
22*f4a2713aSLionel Sambuc   POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}}
23*f4a2713aSLionel Sambuc   StillPOD array3[N]; // expected-warning{{variable length arrays are a C99 feature}}
24*f4a2713aSLionel Sambuc   StillPOD2 array4[N][3]; // expected-warning{{variable length arrays are a C99 feature}}
25*f4a2713aSLionel Sambuc   NonPOD array5[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}}
26*f4a2713aSLionel Sambuc }
27