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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [strlen-2.c] - Blame information for rev 774

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

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2003  Free Software Foundation.
2
 
3
   Test strlen optimizations on conditional expressions.
4
 
5
   Written by Jakub Jelinek, June 23, 2003.  */
6
 
7
typedef __SIZE_TYPE__ size_t;
8
extern size_t strlen (const char *);
9
extern char *strcpy (char *, const char *);
10
extern int memcmp (const void *, const void *, size_t);
11
extern void abort (void);
12
extern int inside_main;
13
 
14
size_t g, h, i, j, k, l;
15
 
16
size_t
17
foo (void)
18
{
19
  if (l)
20
    abort ();
21
  return ++l;
22
}
23
 
24
void
25
main_test (void)
26
{
27
  if (strlen (i ? "foo" + 1 : j ? "bar" + 1 : "baz" + 1) != 2)
28
    abort ();
29
  if (strlen (g++ ? "foo" : "bar") != 3 || g != 1)
30
    abort ();
31
  if (strlen (h++ ? "xfoo" + 1 : "bar") != 3 || h != 1)
32
    abort ();
33
  if (strlen ((i++, "baz")) != 3 || i != 1)
34
    abort ();
35
  /* The following calls might not optimize strlen call away.  */
36
  inside_main = 0;
37
  if (strlen (j ? "foo" + k++ : "bar" + k++) != 3 || k != 1)
38
    abort ();
39
  if (strlen (foo () ? "foo" : "bar") != 3 || l != 1)
40
    abort ();
41
}

powered by: WebSVN 2.1.0

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