Dont add varying values to gori_on_edge mass calculations.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / builtin-sprintf-3.c
blobec55f2673184e09da425e4eed909c80223003374
1 /* PR bootstrap/77676 - powerpc64 and powerpc64le stage2 bootstrap fail
2 Test case derived from the one submitted in the bug. It verifies
3 that the sprintf return value (or value range) optimization is not
4 performed for an unknown string. */
5 /* { dg-do compile } */
6 /* { dg-options "-O2 -Wall -Werror -fdump-tree-optimized -fprintf-return-value" } */
8 #define INT_MAX __INT_MAX__
9 #define INT_MIN (-INT_MAX - 1)
11 extern void string_eq_min_fail ();
12 extern void string_eq_max_fail ();
14 extern void string_lt_0_fail ();
15 extern void string_eq_0_fail ();
16 extern void string_gt_0_fail ();
18 void test_string_eq_min (char *d, const char *s)
20 int n = __builtin_sprintf (d, "%-s", s);
22 /* Verify that the return value is NOT assumed NOT to be INT_MIN
23 or INT_MAX. (This is a white box test based on knowing that
24 the optimization computes its own values of the two constants.) */
25 if (n == INT_MIN) string_eq_min_fail ();
28 void test_string_eq_max (char *d, const char *s)
30 int n = __builtin_sprintf (d, "%-s", s);
32 if (n == INT_MAX) string_eq_max_fail ();
35 void test_string_lt_0 (char *d, const char *s)
37 int n = __builtin_sprintf (d, "%-s", s);
39 /* The return value could be negative when strlen(s) is in excess
40 of 4095 (the maximum number of bytes a single directive is required
41 to handle). */
42 if (n < 0) string_lt_0_fail ();
45 void test_string_eq_0 (char *d, const char *s)
47 int n = __builtin_sprintf (d, "%-s", s);
49 if (n == 0) string_eq_0_fail ();
52 void test_string_gt_0 (char *d, const char *s)
54 int n = __builtin_sprintf (d, "%-s", s);
56 if (n > 0) string_gt_0_fail ();
59 /* { dg-final { scan-tree-dump-times "string_eq_min_fail" 1 "optimized" } } */
60 /* { dg-final { scan-tree-dump-times "string_eq_max_fail" 1 "optimized" } } */
61 /* { dg-final { scan-tree-dump-times "string_lt_0_fail" 1 "optimized" } } */
62 /* { dg-final { scan-tree-dump-times "string_eq_0_fail" 1 "optimized" } } */
63 /* { dg-final { scan-tree-dump-times "string_gt_0_fail" 1 "optimized" } } */