d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)
commitdc7d1c74ffb1cc85e67984632f581d526c783770
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 19 Apr 2021 16:45:32 +0000 (19 18:45 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 19 Apr 2021 17:28:09 +0000 (19 19:28 +0200)
tree467ff1aa4402682685d170e4ab2ee7e9cbe18b2d
parente19c6389966216af5925d2917a206cedc40540e8
d: Fix ICE in when formating a string with '%' or '`' characters (PR98457)

The percentage character was being confused for a format specifier in
pp_format(), whilst the backtick character was confused for the
beginning of a quoted string in expand_d_format().

Both are now properly escaped to avoid the ICE.

gcc/d/ChangeLog:

PR d/98457
* d-diagnostic.cc (expand_d_format): Handle escaped backticks.
(escape_d_format): New funtion.
(verror): Call escape_d_format on prefixing strings.
(vdeprecation): Likewise.

gcc/testsuite/ChangeLog:

PR d/98457
* gdc.dg/pr98457.d: New test.
gcc/d/d-diagnostic.cc
gcc/testsuite/gdc.dg/pr98457.d [new file with mode: 0644]