Commit 0bcf7e67 by Martin Sebor Committed by Martin Sebor

strlenopt-46.c: Define strnlen for targets like Solaris 10 that don't define the function.

gcc/testsuite/ChangeLog:

	* gcc.dg/strlenopt-46.c: Define strnlen for targets like Solaris 10
	that don't define the function.

From-SVN: r262255
parent dd2a4498
2018-06-29 Martin Sebor <msebor@redhat.com>
* gcc.dg/strlenopt-46.c: Define strnlen for targets like Solaris 10
that don't define the function.
2018-06-29 Marek Polacek <polacek@redhat.com>
PR c++/86184
......
/* PR tree-optimization/86204 - wrong strlen result after prior strnlen
{ dg-do run }
{ dg-options "-O2 -Wall" } */
{ dg-options "-O2 -Wall -fdump-tree-optimized" } */
#include "strlenopt.h"
......@@ -129,3 +129,20 @@ int main (void)
gx (2);
gx (7);
}
/* For targets like Solaris 10 that don't define strnlen(). */
NOIPA size_t
strnlen (const char *s, size_t n)
{
size_t len = 0;
while (*s++ && n--)
++len;
return len;
}
/* Verify that at least some of the 11 calls to strnlen have been
folded (this number of folded calls may need to be adjusted up
if the strnlen optimization improves, but it should not go down.
{ dg-final { scan-tree-dump-times "= strnlen" 7 "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment