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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [strlen-3.c] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* Copyright (C) 2004  Free Software Foundation.
2
 
3
   Test strlen on const variables initialized to string literals.
4
 
5
   Written by Jakub Jelinek, 9/14/2004.  */
6
 
7
extern void abort (void);
8
extern __SIZE_TYPE__ strlen (const char *);
9
extern char *strcpy (char *, const char *);
10
static const char bar[] = "Hello, World!";
11
static const char baz[] = "hello, world?";
12
static const char larger[20] = "short string";
13
extern volatile int inside_main;
14
 
15
int l1 = 1;
16
int x = 6;
17
 
18
void
19
main_test(void)
20
{
21
#ifdef __OPTIMIZE__
22
  const char *foo;
23
  int i;
24
#endif
25
 
26
  if (strlen (bar) != 13)
27
    abort ();
28
 
29
  if (strlen (bar + 3) != 10)
30
    abort ();
31
 
32
  if (strlen (&bar[6]) != 7)
33
    abort ();
34
 
35
  if (strlen (bar + (x++ & 7)) != 7)
36
    abort ();
37
  if (x != 7)
38
    abort ();
39
 
40
#ifdef __OPTIMIZE__
41
  foo = bar;
42
  for (i = 0; i < 4; ++i)
43
    {
44
      if (i == l1 - 1)
45
        foo = "HELLO, WORLD!";
46
      else if (i == l1)
47
        foo = bar;
48
      else if (i == l1 + 1)
49
        foo = "hello, world!";
50
      else
51
        foo = baz;
52
    }
53
  if (strlen (foo) != 13)
54
    abort ();
55
#endif
56
 
57
  if (strlen (larger) != 12)
58
    abort ();
59
  if (strlen (&larger[10]) != 2)
60
    abort ();
61
 
62
  inside_main = 0;
63
  /* This will result in strlen call, because larger
64
     array is bigger than its initializer.  */
65
  if (strlen (larger + (x++ & 7)) != 5)
66
    abort ();
67
  if (x != 8)
68
    abort ();
69
  inside_main = 1;
70
}

powered by: WebSVN 2.1.0

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