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/] [builtins/] [pr23484-chk.c] - Blame information for rev 825

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

Line No. Rev Author Line
1 149 jeremybenn
/* PR middle-end/23484 */
2
 
3
extern void abort (void);
4
typedef __SIZE_TYPE__ size_t;
5
extern size_t strlen (const char *);
6
extern void *memcpy (void *, const void *, size_t);
7
extern void *mempcpy (void *, const void *, size_t);
8
extern void *memmove (void *, const void *, size_t);
9
extern int snprintf (char *, size_t, const char *, ...);
10
extern int memcmp (const void *, const void *, size_t);
11
 
12
#include "chk.h"
13
 
14
static char data[8] = "ABCDEFG";
15
 
16
int l1;
17
 
18
void
19
__attribute__((noinline))
20
test1 (void)
21
{
22
  char buf[8];
23
 
24
  /* All the checking calls in this routine have a maximum length, so
25
     object size checking should be done at compile time if optimizing.  */
26
  chk_calls = 0;
27
 
28
  memset (buf, 'I', sizeof (buf));
29
  if (memcpy (buf, data, l1 ? sizeof (buf) : 4) != buf
30
      || memcmp (buf, "ABCDIIII", 8))
31
    abort ();
32
 
33
  memset (buf, 'J', sizeof (buf));
34
  if (mempcpy (buf, data, l1 ? sizeof (buf) : 4) != buf + 4
35
      || memcmp (buf, "ABCDJJJJ", 8))
36
    abort ();
37
 
38
  memset (buf, 'K', sizeof (buf));
39
  if (memmove (buf, data, l1 ? sizeof (buf) : 4) != buf
40
      || memcmp (buf, "ABCDKKKK", 8))
41
    abort ();
42
 
43
  memset (buf, 'L', sizeof (buf));
44
  if (snprintf (buf, l1 ? sizeof (buf) : 4, "%d", l1 + 65536) != 5
45
      || memcmp (buf, "655\0LLLL", 8))
46
    abort ();
47
 
48
  if (chk_calls)
49
    abort ();
50
}
51
 
52
void
53
main_test (void)
54
{
55
#ifndef __OPTIMIZE__
56
  /* Object size checking is only intended for -O[s123].  */
57
  return;
58
#endif
59
  __asm ("" : "=r" (l1) : "0" (l1));
60
  test1 ();
61
}

powered by: WebSVN 2.1.0

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