brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · bb4a48e Raw
55 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s2 3// Simple form4int ar1[10];5 6// Element type cannot be:7// - (cv) void8volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}}9// - a reference10int& ar3[10]; // expected-error {{array of references}}11// - a function type12typedef void Fn();13Fn ar4[10]; // expected-error {{array of functions}}14// - an abstract class15struct 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 type28// is required. (PR5048)29void fun(int p1[], Incomplete p2[10]);30extern int ear1[];31extern Incomplete ear2[10];32 33// cv migrates to element type34typedef const int cint;35extern cint car1[10];36typedef int intar[10];37// thus this is a valid redeclaration38extern 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 declared47// array as this is often used to simulate static_assert with template48// instantiations, placing the 'error message' in the declarator name.49int50user_error_message51[-1]; // expected-error {{user_error_message}}52typedef int53another_user_error_message54[-1]; // expected-error {{another_user_error_message}}55