Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-41.c
blobc5e8eb6d8df8dc5176297d8f7ca9b2a8e6c04786
1 /* PR tree-optimization/83671 - fix for false positive reported by
2 -Wstringop-overflow does not work with inlining
3 Verify that the length the empty string is folded to zero even at -O1
4 regardless of offset into it.
5 Also verify that the length of a non-empty string isn't folded given
6 a variable offset.
7 { dg-do compile }
8 { dg-options "-O1 -fdump-tree-optimized" } */
10 #include "strlenopt.h"
12 inline unsigned length (const char *s)
14 return __builtin_strlen (s);
17 void check_length_cst (int i)
19 unsigned len = length (&""[i]);
21 if (len)
22 __builtin_abort ();
25 void check_length_var (int i)
27 unsigned len = length (&"1"[i]);
29 if (len != 1)
30 __builtin_abort ();
33 /* { dg-final { scan-tree-dump-times "abort" 1 "optimized" } }
34 { dg-final { scan-tree-dump-times "strlen" 1 "optimized" } } */