Skip to content

Commit 73d4d63

Browse files
lkorencxlauko
authored andcommitted
test:compile: Add more union and struct tests.
1 parent 64dc4ce commit 73d4d63

File tree

7 files changed

+127
-0
lines changed

7 files changed

+127
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %vast-front -o %t %s && (%t; test $? -eq 5)
2+
3+
struct data
4+
{
5+
struct nested
6+
{
7+
int a;
8+
} n;
9+
};
10+
11+
int main(int argc, char **argv)
12+
{
13+
struct data d = { { 5 } };
14+
return d.n.a;
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %vast-front -o %t %s && (%t; test $? -eq 5)
2+
3+
union data
4+
{
5+
unsigned long long l;
6+
struct P
7+
{
8+
int a;
9+
int b;
10+
} n;
11+
};
12+
13+
int main(int argc, char **argv)
14+
{
15+
union data d = { 5 };
16+
if (d.n.b != 0)
17+
return 0;
18+
return d.n.a;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %vast-front -o %t %s && (%t; test $? -eq 5)
2+
3+
union data
4+
{
5+
unsigned long long l;
6+
struct P
7+
{
8+
int a;
9+
int b;
10+
} n;
11+
};
12+
13+
int main(int argc, char **argv)
14+
{
15+
union data d;
16+
struct P p = { 1, 2 };
17+
d.n = p;
18+
if (d.l != 0x0000000200000001)
19+
return 128;
20+
return 5;
21+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %vast-front -o %t %s && (%t; test $? -eq 18)
2+
3+
union data
4+
{
5+
int a;
6+
unsigned long long b;
7+
char c;
8+
};
9+
10+
int main(int argc, char **argv)
11+
{
12+
union data d;
13+
d.b = 0xffffffff00000012;
14+
return d.a;
15+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %vast-front -o %t %s && (%t 1 1 1 1; test $? -eq 5)
2+
3+
union data
4+
{
5+
int a;
6+
unsigned long long b;
7+
char c;
8+
};
9+
10+
int main(int argc, char **argv)
11+
{
12+
union data d;
13+
d.b = 0xffffffff00000012;
14+
d.a = argc;
15+
return d.c;
16+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %vast-front -o %t %s && (%t 1 1 1 1; test $? -eq 5)
2+
3+
struct access
4+
{
5+
int l;
6+
int h;
7+
};
8+
9+
union data
10+
{
11+
unsigned long long b;
12+
struct access s;
13+
};
14+
15+
int main(int argc, char **argv)
16+
{
17+
union data d;
18+
d.b = 0xffffffff00000000 + argc;
19+
return d.s.l;
20+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %vast-front -o %t %s && (%t 1 1 1 1; test $? -eq 5)
2+
3+
struct access
4+
{
5+
int l;
6+
int h;
7+
};
8+
9+
union data
10+
{
11+
unsigned long long b;
12+
struct access s;
13+
};
14+
15+
int main(int argc, char **argv)
16+
{
17+
union data d;
18+
d.b = 0xffffffff00000000 + argc;
19+
d.s.h = 0x12;
20+
return d.s.l;
21+
}

0 commit comments

Comments
 (0)