aboutsummaryrefslogtreecommitdiff
path: root/tests/tests2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests2')
-rw-r--r--tests/tests2/86-struct-init.c28
-rw-r--r--tests/tests2/86-struct-init.expect4
2 files changed, 29 insertions, 3 deletions
diff --git a/tests/tests2/86-struct-init.c b/tests/tests2/86-struct-init.c
index 6749f98..6ce4e24 100644
--- a/tests/tests2/86-struct-init.c
+++ b/tests/tests2/86-struct-init.c
@@ -96,6 +96,19 @@ struct Anon gan = { 10, 11 }; // ... which makes it available here.
union UV2 guv4 = {{4,3}}; // and the other inits from above as well
*/
+struct in6_addr {
+ union {
+ u8 u6_addr8[16];
+ unsigned short u6_addr16[8];
+ } u;
+};
+struct flowi6 {
+ struct in6_addr saddr, daddr;
+};
+struct pkthdr {
+ struct in6_addr daddr, saddr;
+};
+struct pkthdr phdr = { { { 6,5,4,3 } }, { { 9,8,7,6 } } };
#include <stdio.h>
void print_ (const char *name, const u8 *p, long size)
{
@@ -107,7 +120,7 @@ void print_ (const char *name, const u8 *p, long size)
}
#define print(x) print_(#x, (u8*)&x, sizeof (x))
#if 1
-void foo (struct W *w)
+void foo (struct W *w, struct pkthdr *phdr_)
{
struct S ls = {1, 2, 3, 4};
struct S ls2 = {1, 2, {3, 4}};
@@ -115,6 +128,9 @@ void foo (struct W *w)
struct U lu = {3, 5,6,7,8, 4, "huhu", 43};
struct U lu1 = {3, ls, 4, {"huhu", 43}};
struct U lu2 = {3, (ls), 4, {"huhu", 43}};
+ const struct S *pls = &ls;
+ struct S ls21 = *pls;
+ struct U lu22 = {3, *pls, 4, {"huhu", 43}};
/* Incomplete bracing. */
struct U lu21 = {3, ls, 4, "huhu", 43};
/* Optional braces around scalar initializers. Accepted, but with
@@ -129,20 +145,25 @@ void foo (struct W *w)
/* Compund literal */
struct V lv2 = {(struct S)w->t.s, {"hihi", 47}, 48};
/* Parens around compound literal */
- struct V lv3 = {((struct S){7,8,{9,10}}), w->t.t, 50};
+ struct V lv3 = {((struct S){7,8,{9,10}}), ((const struct W *)w)->t.t, 50};
+ const struct pkthdr *phdr = phdr_;
+ struct flowi6 flow = { .daddr = phdr->daddr, .saddr = phdr->saddr };
print(ls);
print(ls2);
print(lt);
print(lu);
print(lu1);
print(lu2);
+ print(ls21);
print(lu21);
+ print(lu22);
print(lu3);
print(lu4);
print(ls3);
print(lv);
print(lv2);
print(lv3);
+ print(flow);
}
#endif
@@ -167,7 +188,8 @@ int main()
print(guv.b);
print(guv2);
print(guv3);
- foo(&gw);
+ print(phdr);
+ foo(&gw, &phdr);
//printf("q: %s\n", q);
return 0;
}
diff --git a/tests/tests2/86-struct-init.expect b/tests/tests2/86-struct-init.expect
index a5333dc..b827ec4 100644
--- a/tests/tests2/86-struct-init.expect
+++ b/tests/tests2/86-struct-init.expect
@@ -17,16 +17,20 @@ guv: 6 5 0 0
guv.b: 5
guv2: 8 7 0 0
guv3: 7 8 0 0
+phdr: 6 5 4 3 0 0 0 0 0 0 0 0 0 0 0 0 9 8 7 6 0 0 0 0 0 0 0 0 0 0 0 0
ls: 1 2 3 4
ls2: 1 2 3 4
lt: 68 65 6c 6c 6f 0 0 0 0 0 0 0 0 0 0 0 2a
lu: 3 5 6 7 8 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
lu1: 3 1 2 3 4 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
lu2: 3 1 2 3 4 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
+ls21: 1 2 3 4
lu21: 3 1 2 3 4 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
+lu22: 3 1 2 3 4 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
lu3: 3 5 6 7 8 4 68 75 68 75 0 0 0 0 0 0 0 0 0 0 0 0 2b
lu4: 3 5 6 7 0 5 62 6c 61 0 0 0 0 0 0 0 0 0 0 0 0 0 2c
ls3: 1 2 3 4
lv: 3 4 5 6 68 61 68 61 0 0 0 0 0 0 0 0 0 0 0 0 2d 2e
lv2: 1 2 3 4 68 69 68 69 0 0 0 0 0 0 0 0 0 0 0 0 2f 30
lv3: 7 8 9 a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32
+flow: 9 8 7 6 0 0 0 0 0 0 0 0 0 0 0 0 6 5 4 3 0 0 0 0 0 0 0 0 0 0 0 0