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