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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [strlenopt-8.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O2 -fdump-tree-strlen" } */
3
 
4
#include "strlenopt.h"
5
 
6
/* Yes, there are people who write code like this.  */
7
 
8
__attribute__((noinline, noclone)) char *
9
foo (int r)
10
{
11
  char buf[10] = "";
12
  strcat (buf, r ? "r" : "w");
13
  strcat (buf, "b");
14
  return strdup (buf);
15
}
16
 
17
__attribute__((noinline, noclone)) char *
18
bar (int r)
19
{
20
  char buf[10] = {};
21
  strcat (buf, r ? "r" : "w");
22
  strcat (buf, "b");
23
  return strdup (buf);
24
}
25
 
26
int
27
main ()
28
{
29
  char *q = foo (1);
30
  if (q != NULL)
31
    {
32
      if (strcmp (q, "rb"))
33
        abort ();
34
      free (q);
35
    }
36
  q = bar (0);
37
  if (q != NULL)
38
    {
39
      if (strcmp (q, "wb"))
40
        abort ();
41
      free (q);
42
    }
43
  return 0;
44
}
45
 
46
/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
47
/* { dg-final { scan-tree-dump-times "memcpy \\(" 4 "strlen" } } */
48
/* { dg-final { scan-tree-dump-times "strcpy \\(" 0 "strlen" } } */
49
/* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
50
/* { dg-final { scan-tree-dump-times "strchr \\(" 0 "strlen" } } */
51
/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
52
/* { dg-final { cleanup-tree-dump "strlen" } } */

powered by: WebSVN 2.1.0

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