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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20030408-1.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 688 jeremybenn
/* PR optimization/8634 */
2
/* Contributed by Glen Nakamura <glen at imodulo dot com> */
3
 
4
extern void abort (void);
5
 
6
struct foo {
7
  char a, b, c, d, e, f, g, h, i, j;
8
};
9
 
10
int test1 ()
11
{
12
  const char X[8] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
13
  char buffer[8];
14
  __builtin_memcpy (buffer, X, 8);
15
  if (buffer[0] != 'A' || buffer[1] != 'B'
16
      || buffer[2] != 'C' || buffer[3] != 'D'
17
      || buffer[4] != 'E' || buffer[5] != 'F'
18
      || buffer[6] != 'G' || buffer[7] != 'H')
19
    abort ();
20
  return 0;
21
}
22
 
23
int test2 ()
24
{
25
  const char X[10] = { 'A', 'B', 'C', 'D', 'E' };
26
  char buffer[10];
27
  __builtin_memcpy (buffer, X, 10);
28
  if (buffer[0] != 'A' || buffer[1] != 'B'
29
      || buffer[2] != 'C' || buffer[3] != 'D'
30
      || buffer[4] != 'E' || buffer[5] != '\0'
31
      || buffer[6] != '\0' || buffer[7] != '\0'
32
      || buffer[8] != '\0' || buffer[9] != '\0')
33
    abort ();
34
  return 0;
35
}
36
 
37
int test3 ()
38
{
39
  const struct foo X = { a : 'A', c : 'C', e : 'E', g : 'G', i : 'I' };
40
  char buffer[10];
41
  __builtin_memcpy (buffer, &X, 10);
42
  if (buffer[0] != 'A' || buffer[1] != '\0'
43
      || buffer[2] != 'C' || buffer[3] != '\0'
44
      || buffer[4] != 'E' || buffer[5] != '\0'
45
      || buffer[6] != 'G' || buffer[7] != '\0'
46
      || buffer[8] != 'I' || buffer[9] != '\0')
47
    abort ();
48
  return 0;
49
}
50
 
51
int test4 ()
52
{
53
  const struct foo X = { .b = 'B', .d = 'D', .f = 'F', .h = 'H' , .j = 'J' };
54
  char buffer[10];
55
  __builtin_memcpy (buffer, &X, 10);
56
  if (buffer[0] != '\0' || buffer[1] != 'B'
57
      || buffer[2] != '\0' || buffer[3] != 'D'
58
      || buffer[4] != '\0' || buffer[5] != 'F'
59
      || buffer[6] != '\0' || buffer[7] != 'H'
60
      || buffer[8] != '\0' || buffer[9] != 'J')
61
    abort ();
62
  return 0;
63
}
64
 
65
int main ()
66
{
67
  test1 (); test2 (); test3 (); test4 ();
68
  return 0;
69
}

powered by: WebSVN 2.1.0

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