public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Martin Sebor <msebor@gmail.com>,
	Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 1/4] enhance overflow and truncation detection in strncpy and strncat (PR 81117)
Date: Thu, 10 Aug 2017 05:02:00 -0000	[thread overview]
Message-ID: <7344ba85-0c9f-1602-2a0f-c81fa6cbd7cd@redhat.com> (raw)
In-Reply-To: <33a2ba18-274d-8229-06b4-c4983f0d3e2f@gmail.com>

On 08/06/2017 02:07 PM, Martin Sebor wrote:
> The attached patch adds support for a new GCC format specifier,
> G, that behaves like %K but accepts a gcall* argument.  This
> makes it possible to provide inlining context for "artificial"
> inline functions like strncpy (with _FORTIFY_SOURCE) in
> diagnostics issued from the middle end.
> 
> Martin
> 
> gcc-81117-1.diff
> 
> 
> PR c/81117 - Improve buffer overflow checking in strncpy
> 
> gcc/ChangeLog:
> 
> 	PR c/81117
> 	* tree-diagnostic.c (default_tree_printer): Handle %G.
> 	* tree-pretty-print.h (percent_G_format): Declare new function.
> 	* tree-pretty-print.c (percent_K_format): Define a static overload.
> 	(percent_G_format): New function.
> 
> gcc/c/ChangeLog:
> 
> 	PR c/81117
> 	* c-objc-common.c (c_objc_common_init): Handle 'G'.
> 
> gcc/c-family/ChangeLog:
> 
> 	* c-format.h (T89_G): New macro.
> 	* c-format.c (local_gcall_ptr_node): New variable.
> 	(init_dynamic_diag_info): Initialize it.
> 
> gcc/cp/ChangeLog:
> 
> 	PR c/81117
> 	* error.c (cp_printer): Handle 'G'.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c/81117
> 	* gcc.dg/format/gcc_diag-10.c: Exercise %G.
> 
> diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
> index 52b7e7f..ad58b69 100644
> --- a/gcc/tree-diagnostic.c
> +++ b/gcc/tree-diagnostic.c
> @@ -275,6 +275,10 @@ default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
>        t = va_arg (*text->args_ptr, tree);
>        break;
>  
> +    case 'G':
> +      percent_G_format (text);
> +      return true;
> +
>      case 'K':
>        percent_K_format (text);
>        return true;
> diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
> index 4d8177c..7c4c805 100644
> --- a/gcc/tree-pretty-print.c
> +++ b/gcc/tree-pretty-print.c
> @@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "dumpfile.h"
>  #include "internal-fn.h"
>  #include "gomp-constants.h"
> +#include "gimple.h"
This is an indication you're probably putting the 'G' handling in the
wrong place.  Wouldn't gimple-pretty-print.c be more correct?

That's my only objection to this patch, so if it moves trivially, then
it's pre-approved.  If it's non-trivial, then we'll want another iteration.

jeff

  reply	other threads:[~2017-08-10  4:44 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-08 20:45 [PATCH] " Martin Sebor
2017-07-18  2:51 ` [PING] " Martin Sebor
2017-07-25  3:10   ` [PING #2] " Martin Sebor
2017-07-31 17:29 ` Jeff Law
2017-07-31 19:42   ` Martin Sebor
2017-08-02 16:59     ` Jeff Law
2017-08-06 20:07       ` [PATCH 1/4] " Martin Sebor
2017-08-10  5:02         ` Jeff Law [this message]
2017-08-14 19:21           ` Martin Sebor
2017-08-06 20:07       ` [PATCH 4/4] " Martin Sebor
2017-08-06 20:07       ` [PATCH 2/4] " Martin Sebor
2017-08-10  6:39         ` Jeff Law
2017-08-14 18:04           ` Martin Sebor
2017-08-14 18:29             ` Joseph Myers
2017-08-14 19:26               ` Martin Sebor
2017-08-14 20:41                 ` Joseph Myers
2017-08-14 20:44                   ` Martin Sebor
2017-08-15  3:03                     ` Joseph Myers
2017-11-10 23:03         ` Marc Glisse
2017-11-11 21:10           ` Martin Sebor
2017-08-06 20:07       ` [PATCH 3/4] " Martin Sebor
2017-08-10  7:17         ` Jeff Law
2017-08-10  7:39           ` Richard Biener
2017-08-10 20:21           ` Martin Sebor
2017-08-15  3:06             ` Martin Sebor
2017-08-23 21:11               ` [PING] " Martin Sebor
2017-08-29  5:07                 ` [PING 2] " Martin Sebor
2017-09-19 15:44                   ` [PING 3] " Martin Sebor
2017-09-26  2:27                     ` [PING 4] " Martin Sebor
2017-10-02 22:15             ` Jeff Law
2017-10-21  0:26               ` Martin Sebor
2017-11-04  3:49                 ` Jeff Law
2017-11-10  0:17                   ` Martin Sebor
2017-11-10  0:31                     ` Jeff Law
2017-11-14  9:24         ` [testsuite, committed] Require alloca for c-c++-common/Wstringop-truncation.c Tom de Vries
2017-11-15 15:30         ` [testsuite, committed] Compile strncpy-fix-1.c with -Wno-stringop-truncation Tom de Vries
2017-11-15 15:58           ` Martin Sebor
2017-08-06 20:07       ` [PATCH] enhance overflow and truncation detection in strncpy and strncat (PR 81117) Martin Sebor
2017-08-09 19:21         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7344ba85-0c9f-1602-2a0f-c81fa6cbd7cd@redhat.com \
    --to=law@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=msebor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).