PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / builtin-snprintf-3.c
blobe481955ab7326d39a4da0514761c723fd8839295
1 /* Verify the lower and upper bounds of floating directives with
2 precision whose range crosses zero.
3 { do-do compile }
4 { dg-options "-O2 -Wall -fdump-tree-optimized" } */
6 static const double x = 1.23456789;
8 /* All calls to failure_range must be eliminated. */
9 extern void failure_range (int, int, int);
11 /* All calls to verify_{lo,hi}_bound must be retained. */
12 extern void verify_lo_bound (int, int);
13 extern void verify_hi_bound (int, int);
15 int test_a (int p)
17 if (p < -1 || 3 < p)
18 p = -1;
20 int n = __builtin_snprintf (0, 0, "%.*A", p, x);
21 if (n < 6 || 25 < n)
22 failure_range ('A', 6, 25);
24 if (n == 6) verify_lo_bound ('A', 6);
25 if (n == 25) verify_hi_bound ('A', 25);
27 return n;
30 int test_e (int p)
32 if (p < -1 || 3 < p)
33 p = -1;
35 int n = __builtin_snprintf (0, 0, "%.*E", p, x);
36 if (n < 5 || 17 < n)
37 failure_range ('E', 5, 17);
39 if (n == 5) verify_lo_bound ('E', 5);
40 if (n == 17) verify_hi_bound ('E', 17);
42 return n;
45 int test_f (int p)
47 if (p < -1 || 3 < p)
48 p = -1;
50 int n = __builtin_snprintf (0, 0, "%.*F", p, x);
51 if (n < 1 || 13 < n)
52 failure_range ('F', 1, 13);
54 if (n == 1) verify_lo_bound ('F', 1);
55 if (n == 13) verify_hi_bound ('F', 13);
57 return n;
60 int test_g (int p)
62 if (p < -1 || 3 < p)
63 p = -1;
65 int n = __builtin_snprintf (0, 0, "%.*G", p, x);
66 if (n < 1 || 12 < n)
67 failure_range ('G', 1, 12);
69 if (n == 1) verify_lo_bound ('G', 1);
70 if (n == 12) verify_hi_bound ('G', 12);
72 return n;
75 /* { dg-final { scan-tree-dump-times "snprintf" 4 "optimized"} }
76 { dg-final { scan-tree-dump-not "failure_range" "optimized"} }
77 { dg-final { scan-tree-dump-times "verify_" 8 "optimized"} } */