Commit 9976a810 by Martin Sebor Committed by Martin Sebor

gimple-ssa-sprintf.c (format_floating): Test HAVE_XFmode and HAVE_DFmode before…

gimple-ssa-sprintf.c (format_floating): Test HAVE_XFmode and HAVE_DFmode before using XFmode or DFmode.

gcc/ChangeLog:
	* gimple-ssa-sprintf.c (format_floating): Test HAVE_XFmode and
	HAVE_DFmode before using XFmode or DFmode.
	(parse_directive): Avoid using the z length modifier to avoid
	the ISO C++98 does not support the ‘z’ gnu_printf length modifier.

From-SVN: r244957
parent 31c87a43
2017-01-26 Martin Sebor <msebor@redhat.com> 2017-01-26 Martin Sebor <msebor@redhat.com>
* gimple-ssa-sprintf.c (format_floating): Test HAVE_XFmode and
HAVE_DFmode before using XFmode or DFmode.
(parse_directive): Avoid using the z length modifier to avoid
the ISO C++98 does not support the ‘z’ gnu_printf length modifier.
PR middle-end/78703 PR middle-end/78703
* gimple-ssa-sprintf.c (adjust_for_width_or_precision): Change * gimple-ssa-sprintf.c (adjust_for_width_or_precision): Change
to accept adjustment as an array. to accept adjustment as an array.
......
...@@ -1686,11 +1686,19 @@ format_floating (const directive &dir, tree arg) ...@@ -1686,11 +1686,19 @@ format_floating (const directive &dir, tree arg)
prec[0] = -1; prec[0] = -1;
if (prec[1] < 0) if (prec[1] < 0)
{ {
#ifdef HAVE_XFmode
/* When L is specified use long double, otherwise double. */
unsigned fmtprec unsigned fmtprec
= (dir.modifier == FMT_LEN_L = (dir.modifier == FMT_LEN_L
? REAL_MODE_FORMAT (XFmode)->p ? REAL_MODE_FORMAT (XFmode)->p
: REAL_MODE_FORMAT (DFmode)->p); : REAL_MODE_FORMAT (DFmode)->p);
#elif defined HAVE_DFmode
/* No long double support, use double precision for both. */
unsigned fmtprec = REAL_MODE_FORMAT (DFmode)->p;
#else
/* No long double or double support. */
unsigned fmtprec = 0;
#endif
/* The precision of the IEEE 754 double format is 53. /* The precision of the IEEE 754 double format is 53.
The precision of all other GCC binary double formats The precision of all other GCC binary double formats
is 56 or less. */ is 56 or less. */
...@@ -2706,10 +2714,11 @@ parse_directive (pass_sprintf_length::call_info &info, ...@@ -2706,10 +2714,11 @@ parse_directive (pass_sprintf_length::call_info &info,
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, " Directive %u at offset %zu: \"%.*s\", " fprintf (dump_file, " Directive %u at offset %llu: \"%.*s\", "
"length = %zu\n", "length = %llu\n",
dir.dirno, (size_t)(dir.beg - info.fmtstr), dir.dirno,
(int)dir.len, dir.beg, dir.len); (unsigned long long)(size_t)(dir.beg - info.fmtstr),
(int)dir.len, dir.beg, (unsigned long long)dir.len);
} }
return len - !*str; return len - !*str;
...@@ -3029,8 +3038,8 @@ parse_directive (pass_sprintf_length::call_info &info, ...@@ -3029,8 +3038,8 @@ parse_directive (pass_sprintf_length::call_info &info,
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, " Directive %u at offset %zu: \"%.*s\"", fprintf (dump_file, " Directive %u at offset %llu: \"%.*s\"",
dir.dirno, (size_t)(dir.beg - info.fmtstr), dir.dirno, (unsigned long long)(size_t)(dir.beg - info.fmtstr),
(int)dir.len, dir.beg); (int)dir.len, dir.beg);
if (star_width) if (star_width)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment