OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c99-complit-1.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 689 jeremybenn
/* Test for compound literals: in C99 only.  Test for valid uses.  */
2
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
3
/* { dg-do run } */
4
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
5
 
6
extern void abort (void);
7
extern void exit (int);
8
 
9
struct s { int a; int b; };
10
union u { int c; int d; };
11
 
12
int *i0a = &(int) { 0 };
13
int *i0b = &(int) { 0 };
14
int *i1a = &(int) { 1 };
15
int *i1b = &(int) { 1 };
16
const int *i0c = &(const int) { 0 };
17
 
18
struct s *s0 = &(struct s) { 1, 2 };
19
struct s *s1 = &(struct s) { 1, 2 };
20
const struct s *s2 = &(const struct s) { 1, 2 };
21
 
22
union u *u0 = &(union u) { 3 };
23
union u *u1 = &(union u) { 3 };
24
const union u *u2 = &(const union u) { 3 };
25
 
26
int *a0 = (int []) { 1, 2, 3 };
27
const int *a1 = (const int []) { 1, 2, 3 };
28
 
29
char *p = (char []){ "foo" };
30
 
31
int
32
main (void)
33
{
34
  if (i0a == i0b || i0a == i0c || i0b == i0c)
35
    abort ();
36
  if (i1a == i1b)
37
    abort ();
38
  if (*i0a != 0 || *i0b != 0 || *i1a != 1 || *i1b != 1 || *i0c != 0)
39
    abort ();
40
  *i0a = 1;
41
  *i1a = 0;
42
  if (*i0a != 1 || *i0b != 0 || *i1a != 0 || *i1b != 1 || *i0c != 0)
43
    abort ();
44
  if (s0 == s1 || s1 == s2 || s2 == s0)
45
    abort ();
46
  if (s0->a != 1 || s0->b != 2 || s1->a != 1 || s1->b != 2
47
      || s2->a != 1 || s2->b != 2)
48
    abort ();
49
  s0->a = 2;
50
  s1->b = 1;
51
  if (s0->a != 2 || s0->b != 2 || s1->a != 1 || s1->b != 1
52
      || s2->a != 1 || s2->b != 2)
53
    abort ();
54
  if (u0 == u1 || u1 == u2 || u2 == u0)
55
    abort ();
56
  if (u0->c != 3 || u1->c != 3 || u2->c != 3)
57
    abort ();
58
  u0->d = 2;
59
  if (u0->d != 2 || u1->c != 3 || u2->c != 3)
60
    abort ();
61
  if (a0 == a1)
62
    abort ();
63
  if (a0[0] != 1 || a0[1] != 2 || a0[2] != 3
64
      || a1[0] != 1 || a1[1] != 2 || a1[2] != 3)
65
    abort ();
66
  a0[0] = 3;
67
  if (a0[0] != 3 || a0[1] != 2 || a0[2] != 3
68
      || a1[0] != 1 || a1[1] != 2 || a1[2] != 3)
69
    abort ();
70
  if (p[0] != 'f' || p[1] != 'o' || p[2] != 'o' || p[3] != 0)
71
    abort ();
72
  p[0] = 'g';
73
  if (p[0] != 'g' || p[1] != 'o' || p[2] != 'o' || p[3] != 0)
74
    abort ();
75
  if (sizeof((int []) { 1, 2 ,3 }) != 3 * sizeof(int))
76
    abort ();
77
  if (sizeof((int []) { [3] = 4 }) != 4 * sizeof(int))
78
    abort ();
79
  struct s *y;
80
  for (int i = 0; i < 3; i++) {
81
    struct s *x = &(struct s) { 1, i };
82
    if (x->a != 1 || x->b != i)
83
      abort ();
84
    x->a++;
85
    x->b--;
86
    if (x->a != 2 || x->b != i - 1)
87
      abort ();
88
    if (i && y != x)
89
      abort ();
90
    y = x;
91
  }
92
  int *z;
93
  for (int i = 0; i < 4; i++) {
94
    int *x = (int []){ 0, i, i + 2, i - 3 };
95
    if (x[0] != 0 || x[1] != i || x[2] != i + 2 || x[3] != i - 3)
96
      abort ();
97
    x[0] = x[1];
98
    x[1] *= x[2];
99
    x[2] -= x[3];
100
    x[3] += 7;
101
    if (x[0] != i || x[1] != i * (i + 2) || x[2] != 5 || x[3] != i + 4)
102
      abort ();
103
    if (i && z != x)
104
      abort ();
105
    z = x;
106
  }
107
  (int) { 0 } = 1;
108
  (struct s) { 0, 1 }.a = 3;
109
  (union u) { 3 }.c = 4;
110
  (int []){ 1, 2 }[0] = 0;
111
  exit (0);
112
}

powered by: WebSVN 2.1.0

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