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/] [strpcpy.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
/* Copyright (C) 2003, 2004  Free Software Foundation.
2
 
3
   Ensure builtin stpcpy performs correctly.
4
 
5
   Written by Kaveh Ghazi, 4/11/2003.  */
6
 
7
typedef __SIZE_TYPE__ size_t;
8
 
9
extern void abort (void);
10
extern char *strcpy (char *, const char *);
11
extern char *stpcpy (char *, const char *);
12
extern int memcmp (const void *, const void *, size_t);
13
 
14
extern int inside_main;
15
 
16
const char s1[] = "123";
17
char p[32] = "";
18
char *s2 = "defg";
19
char *s3 = "FGH";
20
size_t l1 = 1;
21
 
22
void
23
main_test (void)
24
{
25
  int i = 8;
26
 
27
#if !defined __i386__ && !defined __x86_64__
28
  /* The functions below might not be optimized into direct stores on all
29
     arches.  It depends on how many instructions would be generated and
30
     what limits the architecture chooses in STORE_BY_PIECES_P.  */
31
  inside_main = 0;
32
#endif
33
  if (stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
34
    abort ();
35
  if (stpcpy (p + 16, "vwxyz" + 1) != p + 16 + 4 || memcmp (p + 16, "wxyz", 5))
36
    abort ();
37
  if (stpcpy (p + 1, "") != p + 1 + 0 || memcmp (p, "a\0cde", 6))
38
    abort ();
39
  if (stpcpy (p + 3, "fghij") != p + 3 + 5 || memcmp (p, "a\0cfghij", 9))
40
    abort ();
41
 
42
  if (stpcpy ((i++, p + 20 + 1), "23") != (p + 20 + 1 + 2)
43
      || i != 9 || memcmp (p + 19, "z\0""23\0", 5))
44
    abort ();
45
 
46
  if (stpcpy (stpcpy (p, "ABCD"), "EFG") != p + 7 || memcmp (p, "ABCDEFG", 8))
47
    abort();
48
 
49
  /* Test at least one instance of the __builtin_ style.  We do this
50
     to ensure that it works and that the prototype is correct.  */
51
  if (__builtin_stpcpy (p, "abcde") != p + 5 || memcmp (p, "abcde", 6))
52
    abort ();
53
 
54
    /* If the result of stpcpy is ignored, gcc should use strcpy.
55
       This should be optimized always, so set inside_main again.  */
56
  inside_main = 1;
57
  stpcpy (p + 3, s3);
58
  if (memcmp (p, "abcFGH", 6))
59
    abort ();
60
}

powered by: WebSVN 2.1.0

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