summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr24615.c
blob: 9e42911750dd463967185003ae7a64d49f64b794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* { dg-do compile { target fpic } } */
/* { dg-options "-Os -fPIC" } */

void *memset (void *, int, __SIZE_TYPE__);
void *memcpy (void *, const void *, __SIZE_TYPE__);

char *alloc (int);

char *
test (int type, int size, char *data, int len)
{
  char *block = alloc (size);
  char *bp = block;

  *bp++ = type;
  switch (type)
    {
    case 0:
    case 1:
      memset (bp, type == 0 ? 0x00 : 0xff, size);
      memcpy (bp, data, len);
    }

  return block;
}