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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [pr44468.c] - Blame information for rev 774

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

Line No. Rev Author Line
1 688 jeremybenn
#include <stddef.h>
2
 
3
struct S {
4
  int i;
5
  int j;
6
};
7
struct R {
8
  int k;
9
  struct S a;
10
};
11
struct Q {
12
  float k;
13
  struct S a;
14
};
15
struct Q s;
16
int __attribute__((noinline,noclone))
17
test1 (void *q)
18
{
19
  struct S *b = (struct S *)((char *)q + sizeof (int));
20
  s.a.i = 0;
21
  b->i = 3;
22
  return s.a.i;
23
}
24
int __attribute__((noinline,noclone))
25
test2 (void *q)
26
{
27
  struct S *b = &((struct R *)q)->a;
28
  s.a.i = 0;
29
  b->i = 3;
30
  return s.a.i;
31
}
32
int __attribute__((noinline,noclone))
33
test3 (void *q)
34
{
35
  s.a.i = 0;
36
  ((struct S *)((char *)q + sizeof (int)))->i = 3;
37
  return s.a.i;
38
}
39
extern void abort (void);
40
int
41
main()
42
{
43
  if (sizeof (float) != sizeof (int)
44
      || offsetof (struct R, a) != sizeof (int)
45
      || offsetof (struct Q, a) != sizeof (int))
46
    return 0;
47
  s.a.i = 1;
48
  s.a.j = 2;
49
  if (test1 ((void *)&s) != 3)
50
    abort ();
51
  s.a.i = 1;
52
  s.a.j = 2;
53
  if (test2 ((void *)&s) != 3)
54
    abort ();
55
  s.a.i = 1;
56
  s.a.j = 2;
57
  if (test3 ((void *)&s) != 3)
58
    abort ();
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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