public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v3 05/11] c: Turn int-conversion warnings into permerrors
Date: Thu, 30 Nov 2023 14:04:37 -0500	[thread overview]
Message-ID: <ZWjcxZ7B9EmPbvwX@redhat.com> (raw)
In-Reply-To: <145518b7d8fc4d04b8d00b69375e27860c5c1000.1700473918.git.fweimer@redhat.com>

On Mon, Nov 20, 2023 at 10:56:09AM +0100, Florian Weimer wrote:
> gcc/
> 
> 	* doc/invoke.texi (Warning Options): Document changes.

Let's be more specific here.
 
> gcc/c/
> 
> 	PR c/96284
> 	PR c/106416
> 	* c-typeck.cc (build_conditional_expr): Use permerror_opt for
> 	pointer/integer type mismatches, based on -Wint-conversion.
> 	(pedwarn_permerror_init, permerror_init): New function.
> 	(pedwarn_init): Call pedwarn_permerror_init.
> 	(convert_for_assignment): Use permerror_opt and
> 	permerror_init for -Wint-conversion	warnings.

A few extra whitespaces.
 
> gcc/testsuite/
> 
> 	* gcc.dg/permerror-default.c (int_conversion_1)
> 	(int_conversion_2): Expect the new permerrors.
> 	* gcc.dg/permerror-gnu89-nopermissive.c (int_conversion_1)
> 	(int_conversion_2): Likewise.
> 	* gcc.dg/permerror-system.c: Likewise.
> 	* c-c++-common/pr77624-1.c (foo, bar): Expect
> 	error instead of warning.
> 	* gcc.dg/Wint-conversion-2.c: Compile with -fpermissive due
> 	to expected int-conversion warning.
> 	* gcc.dg/Wint-conversion-3.c: Likewise.
> 	* gcc.dg/Wint-conversion-4.c: New test.  Based on
> 	gcc.dg/Wint-conversion-3.c.  Expect int-conversion errors.
> 	* gcc.dg/assign-warn-1.c: Compile with -fpermissive.
> 	* gcc.dg/assign-warn-4.c: New file.  Extracted from
> 	assign-warn1.c.  Expect int-cnversion errors.

"int-conversion" (sorry about pointing out typos...)

> 	* gcc.dg/diagnostic-types-1.c: compile with -fpermissive.

s/compile/Compile/

> 	* gcc.dg/diagnostic-types-2.c: New file.  Extracted from
> 	gcc.dg/diagnostic-types-1.c.  Expect some errors instead of
> 	warnings.
> 	* gcc.dg/gomp/pr35738.c: Compile with -fpermissive due to
> 	expected int-conversion error.
> 	* gcc.dg/gomp/pr35738-2.c: New test.  Based on
> 	gcc.dg/gomp/pr35738.c.  Expect int-converison errors.
> 	* gcc.dg/init-excess-3.c: Expect int-converison errors.
> 	* gcc.dg/overflow-warn-1.c: Likewise.
> 	* gcc.dg/overflow-warn-3.c: Likewise.
> 	* gcc.dg/param-type-mismatch.c: Compile with -fpermissive.
> 	* gcc.dg/param-type-mismatch-2.c: New test.  Copied from
> 	gcc.dg/param-type-mismatch.c.  Expect errors.
> 	* gcc.dg/pr61162-2.c: Compile with -fpermissive.
> 	* gcc.dg/pr61162-3.c: New test. Extracted from
> 	gcc.dg/pr61162-2.c.  Expect int-conversion errors.
> 	* gcc.dg/spec-barrier-3.c: Use -fpermissive due to expected
> 	int-conversion error.
> 	* gcc.dg/spec-barrier-3a.c: New test.  Based on
> 	gcc.dg/spec-barrier-3.c.  Expect int-conversion errors.
> 	* gcc.target/aarch64/acle/memtag_2.c: Use -fpermissive due to expected
> 	int-conversion error.
> 	* gcc.target/aarch64/acle/memtag_2a.c: New test.  Copied from
> 	gcc.target/aarch64/acle/memtag_2.c.  Expect error.
> 	* gcc.target/aarch64/sve/acle/general-c/load_3.c (f1): Expect
> 	error.
> 	* gcc.target/aarch64/sve/acle/general-c/store_2.c (f1): Likewise.
> 	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c
> 	(f1): Likewise.
> 	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c
> 	(f1): Likewise.
> 	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c
> 	(f1): Likewise.
> 	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c
> 	(f1): Likewise.
> ---
>  gcc/c/c-typeck.cc                             |  97 +++++----
>  gcc/doc/invoke.texi                           |   6 +
>  gcc/testsuite/c-c++-common/pr77624-1.c        |   4 +-
>  gcc/testsuite/gcc.dg/Wint-conversion-2.c      |   2 +-
>  gcc/testsuite/gcc.dg/Wint-conversion-3.c      |   2 +-
>  gcc/testsuite/gcc.dg/Wint-conversion-4.c      |  14 ++
>  gcc/testsuite/gcc.dg/assign-warn-1.c          |   2 +-
>  gcc/testsuite/gcc.dg/assign-warn-4.c          |  21 ++
>  gcc/testsuite/gcc.dg/diagnostic-types-1.c     |   2 +-
>  gcc/testsuite/gcc.dg/diagnostic-types-2.c     |  24 +++
>  gcc/testsuite/gcc.dg/gomp/pr35738-2.c         |  18 ++
>  gcc/testsuite/gcc.dg/gomp/pr35738.c           |   2 +-
>  gcc/testsuite/gcc.dg/init-excess-3.c          |   4 +-
>  gcc/testsuite/gcc.dg/overflow-warn-1.c        |   4 +-
>  gcc/testsuite/gcc.dg/overflow-warn-3.c        |   4 +-
>  gcc/testsuite/gcc.dg/param-type-mismatch-2.c  | 187 ++++++++++++++++++
>  gcc/testsuite/gcc.dg/param-type-mismatch.c    |   2 +-
>  gcc/testsuite/gcc.dg/permerror-default.c      |  20 +-
>  .../gcc.dg/permerror-gnu89-nopermissive.c     |  20 +-
>  gcc/testsuite/gcc.dg/permerror-system.c       |  13 +-
>  gcc/testsuite/gcc.dg/pr61162-2.c              |   2 +-
>  gcc/testsuite/gcc.dg/pr61162-3.c              |  13 ++
>  gcc/testsuite/gcc.dg/spec-barrier-3.c         |   2 +-
>  gcc/testsuite/gcc.dg/spec-barrier-3a.c        |  13 ++
>  .../gcc.target/aarch64/acle/memtag_2.c        |   4 +-
>  .../gcc.target/aarch64/acle/memtag_2a.c       |  71 +++++++
>  .../aarch64/sve/acle/general-c/load_3.c       |   2 +-
>  .../aarch64/sve/acle/general-c/store_2.c      |   2 +-
>  .../acle/general-c/store_scatter_index_1.c    |   2 +-
>  .../store_scatter_index_restricted_1.c        |   2 +-
>  .../acle/general-c/store_scatter_offset_2.c   |   2 +-
>  .../store_scatter_offset_restricted_1.c       |   2 +-
>  32 files changed, 483 insertions(+), 82 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/Wint-conversion-4.c
>  create mode 100644 gcc/testsuite/gcc.dg/assign-warn-4.c
>  create mode 100644 gcc/testsuite/gcc.dg/diagnostic-types-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/gomp/pr35738-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/param-type-mismatch-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/pr61162-3.c
>  create mode 100644 gcc/testsuite/gcc.dg/spec-barrier-3a.c
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/acle/memtag_2a.c
> 
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index 1dbb4471a88..c7b35a27e3f 100644
> --- a/gcc/c/c-typeck.cc
> +++ b/gcc/c/c-typeck.cc
> @@ -5450,8 +5450,9 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
>  	   && (code2 == INTEGER_TYPE || code2 == BITINT_TYPE))
>      {
>        if (!null_pointer_constant_p (orig_op2))
> -	pedwarn (colon_loc, OPT_Wint_conversion,
> -		 "pointer/integer type mismatch in conditional expression");
> +	permerror_opt (colon_loc, OPT_Wint_conversion,
> +		       "pointer/integer type mismatch "
> +		       "in conditional expression");
>        else
>  	{
>  	  op2 = null_pointer_node;
> @@ -5462,8 +5463,9 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
>  	   && (code1 == INTEGER_TYPE || code1 == BITINT_TYPE))
>      {
>        if (!null_pointer_constant_p (orig_op1))
> -	pedwarn (colon_loc, OPT_Wint_conversion,
> -		 "pointer/integer type mismatch in conditional expression");
> +	permerror_opt (colon_loc, OPT_Wint_conversion,
> +		       "pointer/integer type mismatch "
> +		       "in conditional expression");
>        else
>  	{
>  	  op1 = null_pointer_node;
> @@ -6559,28 +6561,48 @@ error_init (location_t loc, const char *gmsgid, ...)
>      inform (loc, "(near initialization for %qs)", ofwhat);
>  }
>  
> -/* Issue a pedantic warning for a bad initializer component.  OPT is
> -   the option OPT_* (from options.h) controlling this warning or 0 if
> -   it is unconditionally given.  GMSGID identifies the message.  The
> -   component name is taken from the spelling stack.  */
> +/* Used to implement pedwarn_init and permerror_init.  */
>  
>  static void ATTRIBUTE_GCC_DIAG (3,0)
> -pedwarn_init (location_t loc, int opt, const char *gmsgid, ...)
> +pedwarn_permerror_init (location_t loc, int opt, const char *gmsgid,
> +			va_list *ap, diagnostic_t kind)

The declaration changed but the ATTRIBUTE_GCC_DIAG is still correct, ok.

The rest LGTM (though it's tricky to review every line in the testsuite/
changes.)

Marek


  reply	other threads:[~2023-11-30 19:04 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20  9:55 [PATCH v3 00/11] : More warnings as errors by default Florian Weimer
2023-11-20  9:55 ` [PATCH v3 01/11] aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder Florian Weimer
2023-11-22 23:24   ` Joseph Myers
2023-11-20  9:55 ` [PATCH v3 02/11] aarch64: Call named function in gcc.target/aarch64/aapcs64/ice_1.c Florian Weimer
2023-11-22 23:25   ` Joseph Myers
2023-11-20  9:55 ` [PATCH v3 03/11] gm2: Add missing declaration of m2pim_M2RTS_Terminate to test Florian Weimer
2023-11-22 23:28   ` Joseph Myers
2023-11-20  9:56 ` [PATCH v3 04/11] Add tests for validating future C permerrors Florian Weimer
2023-11-30 17:31   ` Marek Polacek
2023-11-30 17:37     ` Florian Weimer
2023-11-30 17:39       ` Marek Polacek
2023-11-30 18:25         ` Jakub Jelinek
2023-11-20  9:56 ` [PATCH v3 05/11] c: Turn int-conversion warnings into permerrors Florian Weimer
2023-11-30 19:04   ` Marek Polacek [this message]
2023-11-30 19:46     ` Florian Weimer
2023-11-20  9:56 ` [PATCH v3 06/11] c: Turn -Wimplicit-function-declaration into a permerror Florian Weimer
2023-11-30 19:15   ` Marek Polacek
2023-12-01 15:54   ` c: Turn -Wimplicit-function-declaration into a permerror: Fix 'gcc.dg/gnu23-builtins-no-dfp-1.c' (was: [PATCH v3 06/11] c: Turn -Wimplicit-function-declaration into a permerror) Thomas Schwinge
2023-12-03  5:55     ` [committed] Fix gnu23-builtins-no-dfp Jeff Law
2023-12-03  7:41       ` Florian Weimer
2023-12-03 12:23         ` Thomas Schwinge
2023-12-03 20:57           ` Jeff Law
2023-12-05  9:31             ` [v2] c: Turn -Wimplicit-function-declaration into a permerror: Fix 'gcc.dg/gnu23-builtins-no-dfp-1.c' (was: [committed] Fix gnu23-builtins-no-dfp) Thomas Schwinge
2024-04-09 11:40   ` [PATCH v3 06/11] c: Turn -Wimplicit-function-declaration into a permerror Sebastian Huber
2024-04-09 12:10     ` Sam James
2024-04-09 12:26       ` Sebastian Huber
2024-04-09 12:56         ` Sam James
2023-11-20  9:56 ` [PATCH v3 07/11] c: Turn -Wimplicit-int " Florian Weimer
2023-11-30 19:48   ` Marek Polacek
2023-11-20  9:56 ` [PATCH v3 08/11] c: Do not ignore some forms of -Wimplicit-int in system headers Florian Weimer
2023-11-30 19:53   ` Marek Polacek
2023-11-20  9:56 ` [PATCH v3 09/11] c: Turn -Wreturn-mismatch into a permerror Florian Weimer
2023-11-23 17:32   ` Marek Polacek
2023-11-23 18:22     ` Florian Weimer
2023-11-30 16:17       ` Marek Polacek
2023-11-20  9:56 ` [PATCH v3 10/11] c: Turn -Wincompatible-pointer-types " Florian Weimer
2023-11-30 20:47   ` Marek Polacek
2023-11-30 21:02   ` Marek Polacek
2023-11-30 21:11     ` Florian Weimer
2023-11-30 21:15       ` Marek Polacek
2023-11-30 21:23         ` Jakub Jelinek
2023-11-30 21:27           ` Florian Weimer
2023-11-30 21:30             ` Jakub Jelinek
2023-11-30 21:36               ` Marek Polacek
2023-12-10 19:23                 ` Jason Merrill
2023-12-05  9:37   ` Richard Earnshaw
2023-12-05  9:46     ` Florian Weimer
2023-12-05 10:11       ` Richard Earnshaw
2023-12-05 10:33       ` [PATCH] libgfortran: Fix -Wincompatible-pointer-types errors Jakub Jelinek
2023-12-05 10:47         ` Richard Earnshaw
2023-12-05 10:51           ` Jakub Jelinek
2023-12-05 10:57             ` Richard Earnshaw
2023-12-05 10:59               ` Jakub Jelinek
2023-12-05 17:35                 ` Richard Earnshaw
2023-12-05 11:00               ` Florian Weimer
2023-12-05 13:35         ` Tobias Burnus
2023-12-06 12:04   ` [PATCH v3 10/11] c: Turn -Wincompatible-pointer-types into a permerror Prathamesh Kulkarni
2023-12-06 12:12     ` Florian Weimer
2023-11-20  9:56 ` [PATCH v3 11/11] c: Add new -Wdeclaration-missing-parameter-type permerror Florian Weimer
2023-11-20 19:12   ` Eric Gallager
2023-11-20 19:32     ` Florian Weimer
2023-11-30 21:10   ` Marek Polacek
2023-12-11  9:11     ` Florian Weimer
2023-11-23  0:54 ` [PATCH v3 00/11] : More warnings as errors by default Jeff Law
2023-11-23  1:04   ` Florian Weimer
2023-11-27 20:23     ` Sam James
2023-11-30 21:35       ` Florian Weimer

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=ZWjcxZ7B9EmPbvwX@redhat.com \
    --to=polacek@redhat.com \
    --cc=fweimer@redhat.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).