Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/Wstringop-overflow-31.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
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" } */ | |
5 | |
6 extern __SIZE_TYPE__ strlen (const char*); | |
7 extern char* strncat (char*, const char*, __SIZE_TYPE__); | |
8 | |
9 | |
10 char a[4]; | |
11 | |
12 | |
13 void f0 (char *d, const char *s) | |
14 { | |
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 } */ | |
17 | |
18 // Prevent f0 from being replaced by g0. | |
19 *d = 'f'; | |
20 } | |
21 | |
22 void f1 (const char *s) | |
23 { | |
24 f0 (a, s); | |
25 } | |
26 | |
27 | |
28 static void g0 (char *d, const char *s) | |
29 { | |
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 } */ | |
32 | |
33 // Prevent g0 from being replaced by f0. | |
34 *d = 'g'; | |
35 } | |
36 | |
37 void g1 (void) | |
38 { | |
39 g0 (a, "123"); | |
40 } |