extern int foof(void) = 1;
static int x, y, z;
static int ary[] = { x, y, z }; int ary2[] = { x, y, z };
extern int fileScopeExtern[3] = { 1, 3, 5 };
static long ary3[] = { 1, "abc", 3, 4 };
void func(void) {
int x = 1;
typedef int TInt = 1;
int xComputeSize[] = { 1, 3, 5 };
int x3[x] = { 1, 2 };
int x4 = { 1, 2 };
int y[4][3] = {
{ 1, 3, 5 },
{ 2, 4, 6 },
{ 3, 5, 7 },
};
int y2[4][3] = {
1, 3, 5, 2, 4, 6, 3, 5, 7
};
int y3[4][3] = {
{ 1, 3, 5 },
{ 2, 4, 6 },
{ 3, 5, 7 },
{ 4, 6, 8 },
{ 5 }, };
struct threeElements {
int a,b,c;
} z = { 1 };
struct threeElements *p = 7;
extern int blockScopeExtern[3] = { 1, 3, 5 };
static long x2[3] = { 1.0,
"abc", 5.8 }; }
void test(void) {
int y1[3] = {
{ 1, 2, 3 } };
int y3[4][3] = {
{ 1, 3, 5 },
{ 2, 4, 6 },
{ 3, 5, 7 },
{ 4, 6, 8 },
{ }, };
int y4[4][3] = {
{ 1, 3, 5, 2 }, { 4, 6 },
{ 3, 5, 7 },
{ 4, 6, 8 },
};
}
void allLegalAndSynonymous(void) {
short q[4][3][2] = {
{ 1 },
{ 2, 3 },
{ 4, 5, 6 }
};
short q2[4][3][2] = {
{ 1, 0, 0, 0, 0, 0 },
{ 2, 3, 0, 0, 0, 0 },
{ 4, 5, 6 }
};
short q3[4][3][2] = {
{
{ 1 },
},
{
{ 2, 3 },
},
{
{ 4, 5 },
{ 6 },
},
};
}
void legal(void) {
short q[][3][2] = {
{ 1 },
{ 2, 3 },
{ 4, 5, 6 }
};
int q_sizecheck[(sizeof(q) / sizeof(short [3][2])) == 3? 1 : -1];
}
unsigned char asso_values[] = { 34 };
int legal2(void) {
return asso_values[0];
}
void illegal(void) {
short q2[4][][2] = { { 1, 0, 0, 0, 0, 0 },
{ 2, 3, 0, 0, 0, 0 },
{ 4, 5, 6 }
};
short q3[4][3][] = { {
{ 1 },
},
{
{ 2, 3 },
},
{
{ 4, 5 },
{ 6 },
},
};
int a[][] = { 1, 2 }; }
typedef int AryT[];
void testTypedef(void)
{
AryT a = { 1, 2 }, b = { 3, 4, 5 };
int a_sizecheck[(sizeof(a) / sizeof(int)) == 2? 1 : -1];
int b_sizecheck[(sizeof(b) / sizeof(int)) == 3? 1 : -1];
}
static char const xx[] = "test";
int xx_sizecheck[(sizeof(xx) / sizeof(char)) == 5? 1 : -1];
static char const yy[5] = "test";
static char const zz[3] = "test";
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexcess-initializers"
static char const zz_quiet[3] = "test";
#pragma clang diagnostic pop
void charArrays(void) {
static char const test[] = "test";
int test_sizecheck[(sizeof(test) / sizeof(char)) == 5? 1 : -1];
static char const test2[] = { "weird stuff" };
static char const test3[] = { "test", "excess stuff" }; #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexcess-initializers"
static char const test3_quiet[] = {"test", "excess stuff"};
#pragma clang diagnostic pop
char* cp[] = { "Hello" };
char c[] = { "Hello" };
int l[sizeof(c) == 6 ? 1 : -1];
int i[] = { "Hello "}; char c2[] = { "Hello", "Good bye" };
int i2[1] = { "Hello" }; char c3[5] = { "Hello" };
char c4[4] = { "Hello" };
int i3[] = {}; }
void variableArrayInit(void) {
int a = 4;
char strlit[a] = "foo"; int b[a] = { 1, 2, 4 }; }
float r1[10] = {{7}}; float r2[] = {{8}}; char r3[][5] = {1,2,3,4,5,6};
int r3_sizecheck[(sizeof(r3) / sizeof(char[5])) == 2? 1 : -1];
char r3_2[sizeof r3 == 10 ? 1 : -1];
float r4[1][2] = {1,{2},3,4}; char r5[][5] = {"aa", "bbb", "ccccc"};
char r6[sizeof r5 == 15 ? 1 : -1];
const char r7[] = "zxcv";
char r8[5] = "5char";
char r9[5] = "6chars"; unsigned char r10[] = __extension__ (_Generic(0, int: (__extension__ "foo" )));
int r11[0] = {};
void autoStructTest(void) {
struct s1 {char a; char b;} t1;
struct s2 {struct s1 c;} t2 = { t1 };
struct s1 t3[] = {t1, t1, "abc", 0}; int t4[sizeof t3 == 6 ? 1 : -1];
}
struct foo { int z; } w;
int bar (void) {
struct foo z = { w }; return z.z;
}
struct s3 {void (*a)(void);} t5 = {autoStructTest};
struct {int a; int b[];} t6 = {1, {1, 2, 3}}; union {char a; int b;} t7[] = {1, 2, 3};
int t8[sizeof t7 == (3*sizeof(int)) ? 1 : -1];
struct bittest{int : 31, a, :21, :12, b;};
struct bittest bittestvar = {1, 2, 3, 4};
int u1 = {}; int u2 = {{3}};
void varArray(void) {
int c[][x] = { 0 }; }
void emptyInit(void) {struct {} x[] = {6};}
void noNamedInit(void) {
struct {int:5;} x[] = {6}; }
struct {int a; int:5;} noNamedImplicit[] = {1,2,3};
int noNamedImplicitCheck[sizeof(noNamedImplicit) == 3 * sizeof(*noNamedImplicit) ? 1 : -1];
struct soft_segment_descriptor {
long ssd_base;
};
static int dblfault_tss;
union uniao { int ola; } xpto[1];
struct soft_segment_descriptor gdt_segs[] = {
{(long) &dblfault_tss},
{ (long)xpto},
};
static void sppp_ipv6cp_up(void);
const struct {} ipcp = { sppp_ipv6cp_up };
struct _Matrix { union { float m[4][4]; }; }; typedef struct _Matrix Matrix;
void test_matrix(void) {
const Matrix mat1 = {
{ { 1.0f, 2.0f, 3.0f, 4.0f,
5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 11.0f, 12.0f,
13.0f, 14.0f, 15.0f, 16.0f } }
};
const Matrix mat2 = {
1.0f, 2.0f, 3.0f, 4.0f,
5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 11.0f, 12.0f,
13.0f, 14.0f, 15.0f, 16.0f
};
}
char badchararray[1] = { badchararray[0], "asdf" };
typedef int int5[5];
int a1[5] = (int[]){1, 2, 3, 4, 5}; int a2[5] = (int[5]){1, 2, 3, 4, 5}; int a3[] = ((int[]){1, 2, 3, 4, 5}); int a4[] = (int[5]){1, 2, 3, 4, 5}; int a5[] = (int5){1, 2, 3, 4, 5};
int a6[5] = (int[]){1, 2, 3};
int nonconst_value(void);
int a7[5] = (int[5]){ 1,
2,
3,
4,
nonconst_value() };
__attribute__((weak)) const unsigned int test10_bound = 10;
char test10_global[test10_bound]; void test10(void) {
char test10_local[test10_bound] = "help"; }