1/*
2 * Copyright 2014, NICTA
3 *
4 * This software may be distributed and modified according to the terms of
5 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
6 * See "LICENSE_BSD2.txt" for details.
7 *
8 * @TAG(NICTA_BSD)
9 */
10
11/*
12 * Accessing nested structs.
13 * Testcase for bug VER-321.
14 */
15struct num {
16  int n;
17};
18
19struct point1 {
20  struct num x, y;
21};
22
23struct point2 {
24  int n[2];
25};
26
27void f(struct point1 *p1, struct point2 *p2) {
28  p1->x.n = p2->n[0];
29  p2->n[1] = p1->y.n;
30}
31
32int test(struct point1 *p1, struct point2 *p2) {
33  f(p1, p2);
34  return p1->x.n == p2->n[0] && p1->y.n == p2->n[1];
35}
36
37struct s1 {
38    unsigned x, y;
39};
40struct s2 {
41    struct s1 x[2];
42};
43struct s3 {
44    struct s2 x, y;
45};
46struct s4 {
47    struct s3 x[2];
48};
49void g(struct s4 *s) {
50    s->x[0].x.x[0].y = s->x[0].x.x[0].x;
51    s->x[0].x.x[1] = s->x[0].x.x[0];
52    s->x[0].y = s->x[0].x;
53    s->x[1] = s->x[0];
54    *s = *s;
55}
56