On 02/16/2018 05:43 AM, Nick Clifton wrote:
Hi David,
Attached is a revised version of the patch which I hope addresses all
of your (very helpful) comments on the v3 patch.
OK to apply once the sources are back on stage 1 ?
Thanks (also) for adding the documentation!
I have just one minor observation/suggestion for the escaped_string
class. Feel free not to change anything, it's just a possible gotcha
if the class were to become more widely used than it is now.
Since the class manages a resource it should ideally make sure it
doesn't try to release the same resource multiple times. I.e., its
copy constructor and assignment operators should either "do the right
thing" (whatever you think that is) or be made inaccessible (or declared
deleted in C++ 11).
For example:
{
escaped_string a;
a.escape ("foo\nbar");
escaped_string b (a);
// b destroys its m_str
// double free in a's destructor here
}
(Some day GCC will have a warning to help detect this pitfall.)
Martin
Cheers
Nick
gcc/ChangeLog
2018-02-09 Nick Clifton <ni...@redhat.com>
PR 84195
* tree.c (escaped_string): New class. Converts an unescaped
string into its escaped equivalent.
(warn_deprecated_use): Use the new class to convert the
deprecation message, if present.
(test_escaped_strings): New self test.
(test_c_tests): Add test_escaped_strings.
* doc/extend.texi (deprecated): Add a note that the
deprecation message is affected by the -fmessage-length
option, and that control characters will be escaped.
(#pragma GCC error): Document this pragma.
(#pragma GCC warning): Likewise.
* doc/invoke.texi (-fmessage-length): Document this option's
effect on the #warning and #error preprocessor directives and
the deprecated attribute.
gcc/testsuite/ChangeLog
2018-02-09 Nick Clifton <ni...@redhat.com>
PR 84195
* gcc.c-torture/compile/pr84195.c: New test.