libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstringop-overflow-31.c
blob24be256a54784760d3b1db7555eb881ea394a1b1
1 /* PR middle-end/93646 - confusing -Wstringop-truncation on strncat where
2 -Wstringop-overflow is expected
3 { dg-do compile }
4 { dg-options "-O2 -Wall" } */
6 extern __SIZE_TYPE__ strlen (const char*);
7 extern char* strncat (char*, const char*, __SIZE_TYPE__);
10 char a[4];
13 void f0 (char *d, const char *s)
15 strncat (d, s, strlen (s)); // { dg-warning "specified bound depends on the length of the source argument" }
16 /* { dg-message "function 'f0'.*inlined from 'f1'" "inlining stack" { target *-*-* } 0 } */
18 // Prevent f0 from being replaced by g0.
19 *d = 'f';
22 void f1 (const char *s)
24 f0 (a, s);
28 static void g0 (char *d, const char *s)
30 strncat (d, s, strlen (s)); // { dg-warning "specified bound 3 equals source length" }
31 /* { dg-message "function 'g0'.*inlined from 'g1'" "inlining stack" { target *-*-* } 0 } */
33 // Prevent g0 from being replaced by f0.
34 *d = 'g';
37 void g1 (void)
39 g0 (a, "123");