1 /* PR tree-optimization/86853 - sprintf optimization for wide strings
2 doesn't account for conversion failure​
3 Exercise wide character handling in an EBCDIC execution charset.
5 { dg-require-iconv "IBM1047" }
6 { dg-options "-O2 -Wall -Wno-format -Wformat-overflow -fexec-charset=IBM1047 -fdump-tree-optimized" } */
8 typedef __WCHAR_TYPE__
wchar_t;
10 /* Exercise wide character constants. */
12 void test_lc_cst (void)
14 /* IBM1047 0x30 maps to ASCII 0x94 which neeed not be representable
15 in the current locale (and the snprintf() call may fail). Verify
16 that snprintf() doesn't assume it is. */
19 int n
= __builtin_snprintf (0, 0, "%lc", wc
);
24 void test_C_cst (void)
26 /* Same as above but for %C and 0x31 which maps to 0x95. */
29 int n
= __builtin_snprintf (0, 0, "%C", wc
);
34 /* Exercise wide character values in known ranges. */
36 void test_lc_range (wchar_t wc
)
38 if (wc
< 0x40 || 0x49 < wc
)
41 int n
= __builtin_snprintf (0, 0, "%lc", wc
);
46 void test_C_range (wchar_t wc
)
48 if (wc
< 0x41 || 0x48 < wc
)
51 int n
= __builtin_snprintf (0, 0, "%C", wc
);
56 /* Exercise unknown wide character values. */
58 void test_var (wchar_t wc
)
60 int n
= __builtin_snprintf (0, 0, "%lc", wc
);
65 /* { dg-final { scan-tree-dump-times "abort" 5 "optimized" } } */