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/] [strrchr.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) 2000, 2003, 2004  Free Software Foundation.
2
 
3
   Ensure all expected transformations of builtin strrchr and rindex
4
   occur and perform correctly.
5
 
6
   Written by Jakub Jelinek, 11/7/2000.  */
7
 
8
extern void abort (void);
9
extern char *strrchr (const char *, int);
10
extern char *rindex (const char *, int);
11
 
12
char *bar = "hi world";
13
int x = 7;
14
 
15
void
16
main_test (void)
17
{
18
  const char *const foo = "hello world";
19
 
20
  if (strrchr (foo, 'x'))
21
    abort ();
22
  if (strrchr (foo, 'o') != foo + 7)
23
    abort ();
24
  if (strrchr (foo, 'e') != foo + 1)
25
    abort ();
26
  if (strrchr (foo + 3, 'e'))
27
    abort ();
28
  if (strrchr (foo, '\0') != foo + 11)
29
    abort ();
30
  if (strrchr (bar, '\0') != bar + 8)
31
    abort ();
32
  if (strrchr (bar + 4, '\0') != bar + 8)
33
    abort ();
34
  if (strrchr (bar + (x++ & 3), '\0') != bar + 8)
35
    abort ();
36
  if (x != 8)
37
    abort ();
38
  /* Test only one instance of rindex since the code path is the same
39
     as that of strrchr. */
40
  if (rindex ("hello", 'z') != 0)
41
    abort ();
42
 
43
  /* Test at least one instance of the __builtin_ style.  We do this
44
     to ensure that it works and that the prototype is correct.  */
45
  if (__builtin_strrchr (foo, 'o') != foo + 7)
46
    abort ();
47
  if (__builtin_rindex (foo, 'o') != foo + 7)
48
    abort ();
49
}

powered by: WebSVN 2.1.0

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