summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/builtin10.C
blob: 8742223a493d4a523832d8bfb43c2cd1cdf5876a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// { dg-do compile { target correct_iso_cpp_string_wchar_protos } }
// { dg-options "-O2 -fdump-tree-optimized" }

#include <cstring>

const void *cv1;
const char *cc1, *cc2, *cc3, *cc4;
void *v1;
char *c1, *c2, *c3, *c4;

void
f1 (void)
{
  cv1 = memchr ("abcba", 'b', 3);
  cc1 = strchr ("abcba", 'b');
  cc2 = strrchr ("abcba", 'b');
  cc3 = strpbrk ("dabc", "abc");
  cc4 = strstr ("aaabc", "abc");
}

void
f2 (void)
{
  cv1 = std::memchr ("abcba", 'b', 3);
  cc1 = std::strchr ("abcba", 'b');
  cc2 = std::strrchr ("abcba", 'b');
  cc3 = std::strpbrk ("dabc", "abc");
  cc4 = std::strstr ("aaabc", "abc");
}

void
f3 (void)
{
  v1 = memchr ((char *)"abcba", 'b', 3);
  c1 = strchr ((char *)"abcba", 'b');
  c2 = strrchr ((char *)"abcba", 'b');
  c3 = strpbrk ((char *)"dabc", "abc");
  c4 = strstr ((char *)"aaabc", "abc");
}

void
f4 (void)
{
  v1 = std::memchr ((char *)"abcba", 'b', 3);
  c1 = std::strchr ((char *)"abcba", 'b');
  c2 = std::strrchr ((char *)"abcba", 'b');
  c3 = std::strpbrk ((char *)"dabc", "abc");
  c4 = std::strstr ((char *)"aaabc", "abc");
}

// { dg-final { scan-tree-dump-not "memchr" "optimized" } }
// { dg-final { scan-tree-dump-not "strchr" "optimized" } }
// { dg-final { scan-tree-dump-not "strrchr" "optimized" } }
// { dg-final { scan-tree-dump-not "strpbrk" "optimized" } }
// { dg-final { scan-tree-dump-not "strstr" "optimized" } }
// { dg-final { cleanup-tree-dump "optimized" } }