This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] have -Wformat-overflow handle -fexec-charset (PR 80503)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Martin Sebor <msebor at gmail dot com>, Joseph Myers <joseph at codesourcery dot com>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 28 Apr 2017 18:27:41 +0200
- Subject: Re: [PATCH] have -Wformat-overflow handle -fexec-charset (PR 80503)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 653CDC059747
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 653CDC059747
- References: <055b63b9-2303-6031-021c-c216e94ed072@gmail.com> <alpine.DEB.2.20.1704262224580.2840@digraph.polyomino.org.uk> <20170426223418.GV1809@tucnak> <7b8f6999-942c-1540-c6e6-a6284d57baf5@gmail.com> <d85393f5-bbf5-4898-579a-7b9c2ba8a624@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Apr 28, 2017 at 10:22:29AM -0600, Jeff Law wrote:
> So the initialization could be done once per translation unit rather than
> once per function -- assuming the target character set doesn't change within
> a translation unit.
>
> That seems like it ought to be easy.
>
> The table-lookup seems like a reasonable cost and I don't think we should
> litter the code with conditionals to conditionally lookup based on whether
> or not the charsets are the same.
One option would be to have the cache array initialized say to 0 for
all chars except for % (which can be taken from target_percent or how is
that called), and then query (and cache) chars you need (you don't need
anything until % is seen, then obviously you need to translate chars
following that until end of the format string is recognized, then again
skip until next % etc.
And/or enhance libcpp and the langhooks so that they will tell you when
the exec charset is identical to host (or at least the subset format strings
care about).
Jakub