1 /* PR tree-optimization/79691 - -Wformat-truncation suppressed by
5 { dg-options "-Og -Wall -fdump-tree-optimized" } */
9 /* Verify -Wformat-overflow works. */
12 __builtin_sprintf (d
, "%i", 123); /* { dg-warning "directive writing 3 bytes" } */
15 /* Verify -Wformat-truncation works. */
18 __builtin_snprintf (d
, sizeof d
, "%i", 1234); /* { dg-warning "output truncated writing 4 bytes" } */
21 /* Verify -fprintf-return-value works. */
24 return __builtin_snprintf (0, 0, "%i", 12345);
27 /* Verify -fprintf-return-value results used for constant propagation. */
30 int n1
= __builtin_snprintf (0, 0, "%i", 1234);
31 int n2
= __builtin_snprintf (0, 0, "%i", 12345);
35 /* { dg-final { scan-tree-dump-times "sprintf" 1 "optimized" } }
36 { dg-final { scan-tree-dump-times "snprintf" 1 "optimized" } }
37 { dg-final { scan-tree-dump " = 9;" "optimized" } } */