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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [string-opt-17.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Test strcpy optimizations don't evaluate side-effects twice.
4
 
5
   Written by Jakub Jelinek, June 23, 2003.  */
6
 
7
typedef __SIZE_TYPE__ size_t;
8
extern char *strcpy (char *, const char *);
9
extern int memcmp (const void *, const void *, size_t);
10
extern void abort (void);
11
extern void exit (int);
12
 
13
size_t
14
test1 (char *s, size_t i)
15
{
16
  strcpy (s, "foobarbaz" + i++);
17
  return i;
18
}
19
 
20
size_t
21
check2 (void)
22
{
23
  static size_t r = 5;
24
  if (r != 5)
25
    abort ();
26
  return ++r;
27
}
28
 
29
void
30
test2 (char *s)
31
{
32
  strcpy (s, "foobarbaz" + check2 ());
33
}
34
 
35
int
36
main (void)
37
{
38
  char buf[10];
39
  if (test1 (buf, 7) != 8 || memcmp (buf, "az", 3))
40
    abort ();
41
  test2 (buf);
42
  if (memcmp (buf, "baz", 4))
43
    abort ();
44
  exit (0);
45
}

powered by: WebSVN 2.1.0

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