1
// RUN: %clang_cc1 -std=c++1y %s -verify -triple=x86_64-linux-gnu -pedantic-errors
3
// FIXME: many diagnostics here say 'variably modified type'.
4
// catch this case and say 'array of runtime bound' instead.
6
namespace std { struct type_info; }
9
int arr[__SIZE_MAX__ / 32];
11
S s[32]; // expected-error {{array is too large}}
14
int a[n]; // expected-error {{not allowed at file scope}}
17
int a[n]; // expected-error {{fields must have a constant size}}
18
static int b[n]; // expected-error {{not allowed at file scope}}
21
int g(int n, int a[n]);
23
template<typename T> struct X {};
24
template<int N, int[N]> struct Y {};
25
template<int[n]> struct Z {}; // expected-error {{of variably modified type}}
28
int arb[n]; // expected-note 3{{here}}
29
[arb] {} (); // expected-error {{cannot be captured}}
31
// FIXME: an array of runtime bound can be captured by reference.
32
[&arb] { // expected-error {{cannot be captured}}
33
// Capturing the array implicitly captures the bound, if we need it
34
// in a range-based for loop.
35
for (auto &n : arb) { } // expected-error {{cannot be captured}}
38
X<int[n]> x; // expected-error {{variably modified type}}
40
int arb_neg[-1]; // expected-error {{negative size}}
41
int arb_of_array[n][2];
42
int arr[3] = { 1, 2, 3, 4 }; // expected-error {{excess elements}}
43
char foo[4] = "fool"; // expected-error {{initializer-string for char array is too long}}
45
static int not_auto1[n]; // expected-error {{can not have 'static'}}
46
extern int not_auto2[n]; // expected-error {{can not have 'extern'}}
47
// FIXME: say 'thread_local' not 'static'.
48
thread_local int not_auto1[n]; // expected-error {{can not have 'static'}}
50
// FIXME: these should all be invalid.
51
auto &&ti1 = typeid(arb);
52
auto &&ti2 = typeid(int[n]);
53
auto &&so1 = sizeof(arb);
54
auto &&so2 = sizeof(int[n]);
58
const int (&arbr)[n] = arbr; // expected-warning {{not yet bound}}
60
int array_of_arb[2][n];
62
struct Dyn { Dyn() {} Dyn(int) {} ~Dyn() {} };
64
// FIXME: these should be valid.
65
int arb_dynamic[n] = { 1, 2, 3, 4 }; // expected-error {{may not be initialized}}
66
Dyn dyn[n]; // expected-error {{non-POD}}
67
Dyn dyn_init[n] = { 1, 2, 3, 4 }; // expected-error {{non-POD}}