re PR tree-optimization/89500 (ICE: tree check: expected integer_cst, have ssa_name...
[gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-10.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wstringop-overflow" } */
3
4 void
5 foo (char *a)
6 {
7 char b[16] = "abcdefg";
8 __builtin_strncpy (a, b, __builtin_strlen (b)); /* { dg-warning "specified bound depends on the length of the source argument" } */
9 }
10
11 void
12 bar (char *a)
13 {
14 char b[16] = "abcdefg";
15 __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-warning "specified bound depends on the length of the source argument" } */
16 }
17
18 void
19 baz (char *a)
20 {
21 char b[16] = "abcdefg";
22 __builtin_strncpy (a, b, __builtin_strnlen (b, 7)); /* { dg-bogus "specified bound depends on the length of the source argument" } */
23 }
24
25 void fill (char *);
26
27 void
28 qux (char *a)
29 {
30 char b[16];
31 fill (b);
32 __builtin_memcpy (b, "abcdefg", 7);
33 __builtin_strncpy (a, b, __builtin_strnlen (b, 8)); /* { dg-bogus "specified bound depends on the length of the source argument" } */
34 }