1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2 
3 // Simple form
4 int ar1[10];
5 
6 // Element type cannot be:
7 // - (cv) void
8 volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}}
9 // - a reference
10 int& ar3[10]; // expected-error {{array of references}}
11 // - a function type
12 typedef void Fn();
13 Fn ar4[10]; // expected-error {{array of functions}}
14 // - an abstract class
15 struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}}
16 Abstract ar5[10]; // expected-error {{abstract class}}
17 
18 // If we have a size, it must be greater than zero.
19 int ar6[-1]; // expected-error {{array with a negative size}}
20 int ar7[0u]; // expected-warning {{zero size arrays are an extension}}
21 
22 // An array with unknown bound is incomplete.
23 int ar8[]; // expected-error {{needs an explicit size or an initializer}}
24 // So is an array with an incomplete element type.
25 struct Incomplete; // expected-note {{forward declaration}}
26 Incomplete ar9[10]; // expected-error {{incomplete type}}
27 // Neither of which should be a problem in situations where no complete type
28 // is required. (PR5048)
29 void fun(int p1[], Incomplete p2[10]);
30 extern int ear1[];
31 extern Incomplete ear2[10];
32 
33 // cv migrates to element type
34 typedef const int cint;
35 extern cint car1[10];
36 typedef int intar[10];
37 // thus this is a valid redeclaration
38 extern const intar car1;
39 
40 // Check that instantiation works properly when the element type is a template.
41 template <typename T> struct S {
42   typename T::type x; // expected-error {{has no members}}
43 };
44 S<int> ar10[10]; // expected-note {{requested here}}
45 
46 // Ensure that negative array size errors include the name of the declared
47 // array as this is often used to simulate static_assert with template
48 // instantiations, placing the 'error message' in the declarator name.
49 int
50 user_error_message
51 [-1]; // expected-error {{user_error_message}}
52 typedef int
53 another_user_error_message
54 [-1]; // expected-error {{another_user_error_message}}
55