public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix PR 108980: note without warning due to array bounds check
Date: Thu, 2 Mar 2023 00:43:48 +0100	[thread overview]
Message-ID: <Y//jNFPazD/TzXiE@tucnak> (raw)
In-Reply-To: <20230301232500.2622240-1-apinski@marvell.com>

On Wed, Mar 01, 2023 at 03:25:00PM -0800, Andrew Pinski via Gcc-patches wrote:
> The problem here is after r13-4748-g2a27ae32fabf85, in some
> cases we were calling inform without a corresponding warning.
> This changes the logic such that we only cause that to happen
> if there was a warning happened before hand.
> 
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
> 
> gcc/ChangeLog:
> 
> 	PR tree-optmization/108980

s/optmization/optimization/

> 	* gimple-array-bounds.cc (array_bounds_checker::check_array_ref):
> 	Reorgnize the call to warning for not strict flexible arrays
> 	to be before the check of warned.
> ---
>  gcc/gimple-array-bounds.cc | 41 ++++++++++++++++++++++++--------------
>  1 file changed, 26 insertions(+), 15 deletions(-)
> 
> diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc
> index 66fd46e9b6c..469baecaa1a 100644
> --- a/gcc/gimple-array-bounds.cc
> +++ b/gcc/gimple-array-bounds.cc
> @@ -397,27 +397,38 @@ array_bounds_checker::check_array_ref (location_t location, tree ref,
>  			       "of an interior zero-length array %qT")),
>  			 low_sub, artype);
>  
> -  if (warned || out_of_bound)
> +  if (warned && dump_file && (dump_flags & TDF_DETAILS))
>      {
> -      if (warned && dump_file && (dump_flags & TDF_DETAILS))
> +      fprintf (dump_file, "Array bound warning for ");
> +      dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
> +      fprintf (dump_file, "\n");
> +    }
> +
> +   /* Issue warnings for -Wstrict-flex-arrays according to the level of
> +      flag_strict_flex_arrays.  */
> +  if (out_of_bound && warn_strict_flex_arrays
> +      && (sam == special_array_member::trail_0
> +	  || sam == special_array_member::trail_1
> +	  || sam == special_array_member::trail_n)
> +      && DECL_NOT_FLEXARRAY (afield_decl))
> +    {
> +      bool warned1;
> +      warned1 = warning_at (location, OPT_Wstrict_flex_arrays,

Why the separate declaration and assignment?
      bool warned1
	= warning_at (location, OPT_Wstrict_flex_arrays,
		      "trailing array %qT should not be used as a flexible "
		      "array member", artype);
looks better.

> +			   "trailing array %qT should not be used as "
> +			   "a flexible array member",
> +			   artype);
> +
> +      if (warned1 && dump_file && (dump_flags & TDF_DETAILS))
>  	{
> -	  fprintf (dump_file, "Array bound warning for ");
> +	  fprintf (dump_file, "Not Flexible array bound warning for ");

Why the capitalization of F ?
Though, I think the wording isn't best anyway.
Perhaps
"Trailing non flexible-like array bound warning for"
?  That is what DECL_NOT_FLEXARRAY is after all, trailing array which
isn't handled like flexible array.

>  	  dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
>  	  fprintf (dump_file, "\n");
>  	}
> +      warned |= warned1;
> +    }
>  

	Jakub


      reply	other threads:[~2023-03-01 23:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 23:25 Andrew Pinski
2023-03-01 23:43 ` Jakub Jelinek [this message]

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=Y//jNFPazD/TzXiE@tucnak \
    --to=jakub@redhat.com \
    --cc=apinski@marvell.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).