gcc/testsuite/ChangeLog:
* gcc.dg/strlenopt-46.c: Define strnlen for targets like Solaris 10
that don't define the function.
From-SVN: r262255
+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"
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" } } */