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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20050826-2.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* PR rtl-optimization/23560 */
2
 
3
struct rtattr
4
{
5
  unsigned short rta_len;
6
  unsigned short rta_type;
7
};
8
 
9
__attribute__ ((noinline))
10
int inet_check_attr (void *r, struct rtattr **rta)
11
{
12
  int i;
13
 
14
  for (i = 1; i <= 14; i++)
15
    {
16
      struct rtattr *attr = rta[i - 1];
17
      if (attr)
18
        {
19
          if (attr->rta_len - sizeof (struct rtattr) < 4)
20
            return -22;
21
          if (i != 9 && i != 8)
22
            rta[i - 1] = attr + 1;
23
        }
24
    }
25
  return 0;
26
}
27
 
28
extern void abort (void);
29
 
30
int
31
main (void)
32
{
33
  struct rtattr rt[2];
34
  struct rtattr *rta[14];
35
  int i;
36
 
37
  rt[0].rta_len = sizeof (struct rtattr) + 8;
38
  rt[0].rta_type = 0;
39
  rt[1] = rt[0];
40
  for (i = 0; i < 14; i++)
41
    rta[i] = &rt[0];
42
  if (inet_check_attr (0, rta) != 0)
43
    abort ();
44
  for (i = 0; i < 14; i++)
45
    if (rta[i] != &rt[i != 7 && i != 8])
46
      abort ();
47
  for (i = 0; i < 14; i++)
48
    rta[i] = &rt[0];
49
  rta[1] = 0;
50
  rt[1].rta_len -= 8;
51
  rta[5] = &rt[1];
52
  if (inet_check_attr (0, rta) != -22)
53
    abort ();
54
  for (i = 0; i < 14; i++)
55
    if (i == 1 && rta[i] != 0)
56
      abort ();
57
    else if (i != 1 && i <= 5 && rta[i] != &rt[1])
58
      abort ();
59
    else if (i > 5 && rta[i] != &rt[0])
60
      abort ();
61
  return 0;
62
}

powered by: WebSVN 2.1.0

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