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