repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git]
/
gcc
/
testsuite
/
gcc.c-torture
/
execute
/
builtins
/
lib
/
strstr.c
blob
7d35445063e44d8efbc8d4c59753dbedebf2c756
1
extern
void
abort
(
void
);
2
extern
int
inside_main
;
3
4
__attribute__
((
__noinline__
))
5
char
*
6
strstr
(
const char
*
s1
,
const char
*
s2
)
7
{
8
const char
*
p
, *
q
;
9
10
#ifdef __OPTIMIZE__
11
if
(
inside_main
)
12
abort
();
13
#endif
14
15
/* deliberately dumb algorithm */
16
for
(; *
s1
;
s1
++)
17
{
18
p
=
s1
,
q
=
s2
;
19
while
(*
q
&& *
p
)
20
{
21
if
(*
q
!= *
p
)
22
break
;
23
p
++,
q
++;
24
}
25
if
(*
q
==
0
)
26
return
(
char
*)
s1
;
27
}
28
return
0
;
29
}