This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR C++/61038] - g++ -E is unusable with UDL strings
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Tue, 13 May 2014 17:29:28 +0000
- Subject: Re: [PATCH, PR C++/61038] - g++ -E is unusable with UDL strings
- Authentication-results: sourceware.org; auth=none
- References: <5371859C dot 3050502 at verizon dot net>
On Mon, 12 May 2014, Ed Smith-Rowland wrote:
> This patch is really a libcpp patch. But UDLs are like that ;-)
>
> Add string user-defined literals and char user-defined literals to the list of
> things to look out for while escaping strings in macro args.
>
> I'm not sure how to test this really. we want to write out *.ii files and
> verify that internal quotes are escaped.
You should be able to check the results of stringizing twice, e.g.:
extern "C" int strcmp (const char *, const char *);
extern "C" void abort (void);
extern "C" void exit (int);
void operator "" _s(const char *, unsigned long)
{
}
#define QUOTE(s) #s
#define QQUOTE(s) QUOTE(s)
const char *s = QQUOTE(QUOTE("hello"_s));
const char *t = QUOTE("\"hello\"_s");
int main()
{
if (strcmp(s, t) == 0)
exit(0);
else
abort();
}
(at least, this fails for me with unmodified GCC, and I think it should
pass).
--
Joseph S. Myers
joseph@codesourcery.com