OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [c99-init-1.c] - Blame information for rev 484

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* Test for C99 designated initializers */
2
/* Origin: Jakub Jelinek <jakub@redhat.com> */
3
/* { dg-do run } */
4
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
5 484 jeremybenn
/* { dg-xfail-if "" { target { ! wchar }  } { "*" } { "" } } */
6 298 jeremybenn
 
7
typedef __SIZE_TYPE__ size_t;
8
typedef __WCHAR_TYPE__ wchar_t;
9
extern int memcmp (const void *, const void *, size_t);
10
extern void abort (void);
11
extern void exit (int);
12
 
13
int a[10] = { 10, 0, 12, 13, 14, 0, 0, 17, 0, 0 };
14
int b[10] = { 10, [4] = 15, [2] = 12, [4] = 14, [7] = 17 };
15
int c[10] = { 10, [4] = 15, [2] = 12, [3] = 13, 14, [7] = 17 };
16
struct A {
17
  int B;
18
  short C[2];
19
};
20
struct A d[] = { { 0, { 1, 2 } }, { 0, { 0, 0 } }, { 10, { 11, 12 } } };
21
struct A e[] = { 0, 1, 2, [2] = 10, 11, 12 };
22
struct A f[] = { 0, 1, 2, [2].C = 11, 12, 13 };
23
struct A g[] = { 0, 1, 2, [2].C[1] = 12, 13, 14 };
24
struct A h[] = { 0, 1, 2, [2] = { .C[1] = 12 }, 13, 14 };
25
struct A i[] = { 0, 1, 2, [2] = { .C = { [1] = 12 } }, 13, 14 };
26
union D {
27
  int E;
28
  double F;
29
  struct A G;
30
};
31
union D j[] = { [4] = 1, [4].F = 1.0, [1].G.C[1] = 4 };
32
struct H {
33
  char I[6];
34
  int J;
35
} k[] = { { { "foo" }, 1 }, [0].I[0] = 'b' };
36
struct K {
37
  wchar_t L[6];
38
  int M;
39
} l[] = { { { L"foo" }, 1 }, [0].L[2] = L'x', [0].L[4] = L'y' };
40
struct H m[] = { { { "foo" }, 1 }, [0] = { .I[0] = 'b' } };
41
struct H n[] = { { { "foo" }, 1 }, [0].I = { "a" }, [0].J = 2 };
42
int o = { 22 };
43
 
44
int main (void)
45
{
46
  if (b[3])
47
    abort ();
48
  b[3] = 13;
49
  if (memcmp (a, b, sizeof (a)) || memcmp (a, c, sizeof (a)))
50
    abort ();
51
  if (memcmp (d, e, sizeof (d)) || sizeof (d) != sizeof (e))
52
    abort ();
53
  if (f[2].B != 0 || g[2].B != 0 || g[2].C[0] != 0)
54
    abort ();
55
  if (memcmp (g, h, sizeof (g)) || memcmp (g, i, sizeof (g)))
56
    abort ();
57
  f[2].B = 10;
58
  g[2].B = 10;
59
  g[2].C[0] = 11;
60
  if (memcmp (d, f, sizeof (d)) || memcmp (d, g, sizeof (d)))
61
    abort ();
62
  if (f[3].B != 13 || g[3].B != 13 || g[3].C[0] != 14)
63
    abort ();
64
  if (j[0].E || j[1].G.B || j[1].G.C[0] || j[1].G.C[1] != 4)
65
    abort ();
66
  if (j[2].E || j[3].E || j[4].F != 1.0)
67
    abort ();
68
  if (memcmp (k[0].I, "boo\0\0", 6) || k[0].J != 1)
69
    abort ();
70
  if (memcmp (l[0].L, L"fox\0y", 6 * sizeof(wchar_t)) || l[0].M != 1)
71
    abort ();
72
  if (memcmp (m[0].I, "b\0\0\0\0", 6) || m[0].J)
73
    abort ();
74
  if (memcmp (n[0].I, "a\0\0\0\0", 6) || n[0].J != 2)
75
    abort ();
76
  if (o != 22)
77
    abort ();
78
  exit (0);
79
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.