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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [Warray-bounds-3.c] - Blame information for rev 689

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-O2 -Warray-bounds" } */
3
/* based on PR 31227 */
4
 
5
typedef __SIZE_TYPE__ size_t;
6
 
7
extern size_t strlen (const char *);
8
 
9
struct iovec
10
{
11
  void *iov_base;
12
  size_t iov_len;
13
};
14
 
15
struct S
16
{
17
  const char *abday[7];
18
  const char *day[7];
19
  const char *abmon[12];
20
  const char *mon[12];
21
  const char *am_pm[2];
22
};
23
 
24
extern void foo (size_t, struct iovec *);
25
 
26
void
27
bar (struct S *time)
28
{
29
  struct iovec iov[43];
30
  size_t cnt;
31
  iov[0].iov_base = (void *) "abc";
32
  iov[0].iov_len = 3;
33
 
34
  iov[1].iov_base = (void *) "def";
35
  iov[1].iov_len = 3;
36
 
37
  for (cnt = 0; cnt <= 7; ++cnt)
38
    {
39
      iov[2 + cnt].iov_base = (void *) (time->abday[cnt] ?: "");
40
      iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
41
    }
42
 
43
  for (; cnt <= 14; ++cnt)
44
    {
45
      iov[2 + cnt].iov_base = (void *) (time->day[cnt - 7] ?: "");
46
      iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
47
    }
48
 
49
  for (; cnt <= 26; ++cnt)
50
    {
51
      iov[2 + cnt].iov_base = (void *) (time->abmon[cnt - 14] ?: "");
52
      iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
53
    }
54
 
55
  for (; cnt <= 38; ++cnt)
56
    {
57
      iov[2 + cnt].iov_base = (void *) (time->mon[cnt - 26] ?: "");
58
      iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
59
    }
60
 
61
  for (; cnt <= 40; ++cnt)
62
    {
63
      iov[2 + cnt].iov_base =  (void *) (time->am_pm[cnt - 38] ?: "");
64
      iov[2 + cnt].iov_len = strlen (iov[2 + cnt].iov_base) + 1;
65
    }
66
 
67
  foo (2 + cnt, iov);
68
}
69
 
70
struct malloc_chunk {
71
  long prev_size;
72
  long size;
73
  struct malloc_chunk* fd;
74
  struct malloc_chunk* bk;
75
};
76
typedef struct malloc_chunk* mchunkptr;
77
struct malloc_state {
78
  mchunkptr        top;
79
  mchunkptr        last_remainder;
80
  mchunkptr        bins[128 * 2 - 2];
81
};
82
#define bin_at(m, i) \
83
  (mchunkptr) (((char *) &((m)->bins[((i) - 1) * 2]))                         \
84
             - __builtin_offsetof (struct malloc_chunk, fd))
85
 
86
void malloc_init_state(struct malloc_state *av)
87
{
88
  int     i;
89
  mchunkptr bin;
90
 
91
  for (i = 1; i < 128; ++i) {
92
    bin = bin_at(av,i);
93
    bin->fd = bin->bk = bin;
94
  }
95
}
96
 
97
typedef unsigned short WCHAR;
98
typedef WCHAR *LPWSTR;
99
 
100
static void g(LPWSTR dest, int len) {
101
     dest[len-1] = 0;
102
}
103
 
104
void f() {
105
    WCHAR szPathW[260];
106
 
107
    g(szPathW, 260);
108
}

powered by: WebSVN 2.1.0

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