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 09/11] c: Turn -Wreturn-mismatch into a permerror
Date: Thu, 23 Nov 2023 12:32:43 -0500	[thread overview]
Message-ID: <ZV+Mu183fSDb2P3R@redhat.com> (raw)
In-Reply-To: <2a00ce2d44edbda185460d72519a879fbac9bf59.1700473918.git.fweimer@redhat.com>

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

That's pretty vague :).  How about "Document that -Wreturn-mismatch is a
permerror in C99."?
 
> gcc/c/
> 
> 	PR c/96284
> 	* c-typeck.cc (c_finish_return): Use permerrors
> 	for OPT_Wreturn_mismatch diagnostics.
> 
> gcc/testsuite/
> 
> 	* gcc.dg/permerror-default.c (return_mismatch_1)
> 	(return_mismatch_2): Expect new permerror.
> 	* gcc.dg/permerror-gnu89-nopermissive.c (return_mismatch_1):
> 	Likewise.
> 	* gcc.dg/permerror-system.c: Likewise.
> 	* gcc.dg/20030906-1.c: Compile with -fpermissive due to
> 	expected -Wreturn-mismatch error.
> 	* gcc.dg/20030906-1a.c: New test.  Copied from
> 	gcc.dg/20030906-1.c.  Expect the error.
> 	* gcc.dg/20030906-2.c: Compile with -fpermissive due to
> 	expected -Wreturn-mismatch error.
> 	* gcc.dg/20030906-2a.c: New test.  Copied from
> 	gcc.dg/20030906-2.c.  Expect the error.
> 	* gcc.dg/Wreturn-mismatch-1.c: Compile with -fpermissive due to
> 	expected -Wreturn-mismatch error.
> 	* gcc.dg/Wreturn-mismatch-1a.c: New test.  Copied from
> 	gcc.dg/Wreturn-mismatch-1.c.  Expect the error.
> 	* gcc.dg/Wreturn-mismatch-2.c: Compile with -fpermissive due to
> 	expected -Wreturn-mismatch error.
> 	* gcc.dg/Wreturn-mismatch-2a.c: New test.  Copied from
> 	gcc.dg/Wreturn-mismatch-2.c.  Expect the error.
> 	* gcc.dg/diagnostic-range-bad-return.c: Compile with
> 	-fpermissive due to expected -Wreturn-mismatch error.
> 	* gcc.dg/diagnostic-range-bad-return-2.c: New test.
> 	Copied from gcc.dg/diagnostic-range-bad-return.c.  Expect the
> 	error.
> 	* gcc.dg/pr105635-2.c: Expect -Wreturn-mismatch error.
> 	* gcc.dg/pr23075.c: Build with -fpermissive due to
> 	expected -Wreturn-mismatch error.
> 	* gcc.dg/pr23075-2.c: New test.  Copied from gcc.dg/pr23075.c.
> 	Expect the error.
> 	* gcc.dg/pr29521.c: Compile with -fpermissive due to expected
> 	-Wreturn-mismatch error.
> 	* gcc.dg/pr29521-a.c: New test. Copied from gcc.dg/pr29521.c.
> 	Expect error.
> 	* gcc.dg/pr67730.c: Compile with -fpermissive due to expected
> 	-Wreturn-mismatch error.
> 	* gcc.dg/pr67730-a.c: New test.  Copied from
> 	gcc.dg/pr67730-a.c.  Expect error.
> 	* gcc.target/powerpc/conditional-return.c: Compile with
> 	-fpermissive due to expected	-Wreturn-mismatch error.

There seem to be some extra whitespaces after "expected".

> ---
>  gcc/c/c-typeck.cc                             |  4 +-
>  gcc/doc/invoke.texi                           |  6 ++-
>  gcc/testsuite/gcc.dg/20030906-1.c             |  2 +-
>  gcc/testsuite/gcc.dg/20030906-1a.c            | 21 ++++++++
>  gcc/testsuite/gcc.dg/20030906-2.c             |  2 +-
>  gcc/testsuite/gcc.dg/20030906-2a.c            | 21 ++++++++
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c     |  2 +-
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c    | 40 ++++++++++++++
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c     |  2 +-
>  gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c    | 41 +++++++++++++++
>  .../gcc.dg/diagnostic-range-bad-return-2.c    | 52 +++++++++++++++++++
>  .../gcc.dg/diagnostic-range-bad-return.c      |  2 +-
>  gcc/testsuite/gcc.dg/permerror-default.c      |  4 +-
>  .../gcc.dg/permerror-gnu89-nopermissive.c     |  2 +-
>  gcc/testsuite/gcc.dg/permerror-system.c       |  3 ++
>  gcc/testsuite/gcc.dg/pr105635-2.c             |  2 +-
>  gcc/testsuite/gcc.dg/pr23075-2.c              | 14 +++++
>  gcc/testsuite/gcc.dg/pr23075.c                |  2 +-
>  gcc/testsuite/gcc.dg/pr29521-a.c              | 15 ++++++
>  gcc/testsuite/gcc.dg/pr29521.c                |  2 +-
>  gcc/testsuite/gcc.dg/pr67730-a.c              | 11 ++++
>  gcc/testsuite/gcc.dg/pr67730.c                |  2 +-
>  .../gcc.target/powerpc/conditional-return.c   |  2 +-
>  23 files changed, 238 insertions(+), 16 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/20030906-1a.c
>  create mode 100644 gcc/testsuite/gcc.dg/20030906-2a.c
>  create mode 100644 gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c
>  create mode 100644 gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c
>  create mode 100644 gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/pr23075-2.c
>  create mode 100644 gcc/testsuite/gcc.dg/pr29521-a.c
>  create mode 100644 gcc/testsuite/gcc.dg/pr67730-a.c
> 
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index c7b35a27e3f..f4b700117ff 100644
> --- a/gcc/c/c-typeck.cc
> +++ b/gcc/c/c-typeck.cc
> @@ -11205,7 +11205,7 @@ c_finish_return (location_t loc, tree retval, tree origtype)
>  	  && valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
>  	{
>  	  no_warning = true;
> -	  if (emit_diagnostic (flag_isoc99 ? DK_PEDWARN : DK_WARNING,
> +	  if (emit_diagnostic (flag_isoc99 ? DK_PERMERROR : DK_WARNING,
>  			       loc, OPT_Wreturn_mismatch,
>  			       "%<return%> with no value,"
>  			       " in function returning non-void"))
> @@ -11218,7 +11218,7 @@ c_finish_return (location_t loc, tree retval, tree origtype)
>        current_function_returns_null = 1;
>        bool warned_here;
>        if (TREE_CODE (TREE_TYPE (retval)) != VOID_TYPE)
> -	warned_here = pedwarn
> +	warned_here = permerror_opt
>  	  (xloc, OPT_Wreturn_mismatch,
>  	   "%<return%> with a value, in function returning void");
>        else
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index eb7417fd9be..831242d134b 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -6185,6 +6185,7 @@ that have their own flag:
>  -Wimplicit-int @r{(C)}
>  -Wint-conversion @r{(C)}
>  -Wnarrowing @r{(C++)}
> +-Wreturn-mismatch @r{(C)}
>  }
>  
>  The @option{-fpermissive} option is the default for historic C language
> @@ -7375,7 +7376,10 @@ Attempting to use the return value of a non-@code{void} function other
>  than @code{main} that flows off the end by reaching the closing curly
>  brace that terminates the function is undefined.
>  
> -This warning is specific to C and enabled by default.
> +This warning is specific to C and enabled by default.  In C99 and later
> +language dialects, it is treated as an error.  It an be downgraded

an -> can

> +to a warning using @option{-fpermissive} (along with other warnings),
> +or for just this warning, with @option{-Wno-error=return-mismatch}.
>  
>  @opindex Wreturn-type
>  @opindex Wno-return-type
> diff --git a/gcc/testsuite/gcc.dg/20030906-1.c b/gcc/testsuite/gcc.dg/20030906-1.c
> index c416f55ee75..6ba5b3d770a 100644
> --- a/gcc/testsuite/gcc.dg/20030906-1.c
> +++ b/gcc/testsuite/gcc.dg/20030906-1.c
> @@ -2,7 +2,7 @@
>     Copyright (C) 2003 Free Software Foundation Inc.  */
>  
>  /* { dg-do compile } */
> -/* { dg-options "-O -finline-functions -Wreturn-type" } */
> +/* { dg-options "-fpermissive -O -finline-functions -Wreturn-type" } */
>  
>  extern int i;
>  extern int foo (void);
> diff --git a/gcc/testsuite/gcc.dg/20030906-1a.c b/gcc/testsuite/gcc.dg/20030906-1a.c
> new file mode 100644
> index 00000000000..46ca1771a4d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/20030906-1a.c
> @@ -0,0 +1,21 @@
> +/* Bug 9862 -- Spurious warnings with -finline-functions.
> +   Copyright (C) 2003 Free Software Foundation Inc.  */
> +
> +/* { dg-do compile } */
> +/* { dg-options "-O -finline-functions -Wreturn-type" } */
> +
> +extern int i;
> +extern int foo (void);
> +extern int bar (void);
> +
> +int foo (void)
> +{
> +  if( i ) return 0;
> +  else    return 1;
> +}
> +
> +int bar (void)
> +{
> +  if( i ) return; /* { dg-error "'return' with no value, in function returning non-void" } */
> +  else    return 1;
> +}		
> diff --git a/gcc/testsuite/gcc.dg/20030906-2.c b/gcc/testsuite/gcc.dg/20030906-2.c
> index 1191133e6a0..a85d91f46f3 100644
> --- a/gcc/testsuite/gcc.dg/20030906-2.c
> +++ b/gcc/testsuite/gcc.dg/20030906-2.c
> @@ -2,7 +2,7 @@
>     Copyright (C) 2003 Free Software Foundation Inc.  */
>  
>  /* { dg-do compile } */
> -/* { dg-options "-O -finline-functions -Wreturn-type" } */
> +/* { dg-options "-fpermissive -O -finline-functions -Wreturn-type" } */
>  
>  extern int i;
>  extern int foo (void);
> diff --git a/gcc/testsuite/gcc.dg/20030906-2a.c b/gcc/testsuite/gcc.dg/20030906-2a.c
> new file mode 100644
> index 00000000000..a6ffbacb46d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/20030906-2a.c
> @@ -0,0 +1,21 @@
> +/* Bug 9862 -- Spurious warnings with -finline-functions.
> +   Copyright (C) 2003 Free Software Foundation Inc.  */
> +
> +/* { dg-do compile } */
> +/* { dg-options "-O -finline-functions -Wreturn-type" } */
> +
> +extern int i;
> +extern int foo (void);
> +extern int bar (void);
> +
> +int foo (void)
> +{
> +  if( i ) return; /* { dg-error "'return' with no value, in function returning non-void" } */
> +  else    return 1;
> +}
> +
> +int bar (void)
> +{
> +  if( i ) return 0;
> +  else    return 1;
> +}
> diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c
> index 3bad847ecf7..aef6782cbeb 100644
> --- a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c
> +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "" } */
> +/* { dg-options "-fpermissive" } */
>  
>  void f1 (void);
>  
> diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c
> new file mode 100644
> index 00000000000..70c7c9ddb86
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-1a.c
> @@ -0,0 +1,40 @@
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +void f1 (void);
> +
> +int
> +f2 (void)
> +{
> +  f1 ();
> +}
> +
> +static inline int
> +f3 (void)
> +{
> +  f1 ();
> +}
> +
> +void
> +f4 (void)
> +{
> +  return 1; /* { dg-error "'return' with a value\[^\n\r\]*-Wreturn-mismatch" } */
> +}
> +
> +void
> +f5 (void)
> +{
> +  return f1 (); /* { dg-bogus "ISO C" } */
> +}
> +
> +int
> +f6 (void)
> +{
> +  return; /* { dg-error "'return' with no value\[^\n\r\]*-Wreturn-mismatch" } */
> +}
> +
> +int
> +f7 (void)
> +{
> +  return f1 (); /* { dg-error "void value not ignored as it ought to be" } */
> +}
> diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c
> index 49eb5a5a95c..08811024b7e 100644
> --- a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c
> +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-Wall" } */
> +/* { dg-options "-fpermissive -Wall" } */
>  
>  void f1 (void);
>  
> diff --git a/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c
> new file mode 100644
> index 00000000000..836651ed925
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/Wreturn-mismatch-2a.c
> @@ -0,0 +1,41 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Wall" } */
> +
> +void f1 (void);
> +
> +int
> +f2 (void)
> +{
> +  f1 ();
> +} /* { dg-warning "control reaches end of non-void\[^\n\r\]*-Wreturn-type" } */
> +
> +static inline int
> +f3 (void)
> +{
> +  f1 ();
> +} /* { dg-warning "no return statement in function\[^\n\r\]*-Wreturn-type" } */
> +
> +void
> +f4 (void)
> +{
> +  return 1; /* { dg-error "with a value,\[^\n\r\]*-Wreturn-mismatch" } */
> +}
> +
> +void
> +f5 (void)
> +{
> +  return f1 ();
> +}
> +
> +int
> +f6 (void)
> +{
> +  return; /* { dg-error "with no value,\[^\n\r\]*Wreturn-mismatch" } */
> +}
> +
> +int
> +f7 (void)
> +{
> +  return f1 (); /* { dg-error "void value not ignored as it ought to be" } */
> +} /* { dg-warning "control reaches end of non-void\[^\n\r\]*-Wreturn-type" } */
> +
> diff --git a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c
> new file mode 100644
> index 00000000000..2fe8d341dba
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return-2.c
> @@ -0,0 +1,52 @@
> +/* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */
> +
> +int *address_of_local (void)
> +{
> +  int some_local;
> +  return &some_local; /* { dg-warning "function returns address of local variable" } */
> +/* { dg-begin-multiline-output "" }
> +   return &some_local;
> +          ^~~~~~~~~~~
> +   { dg-end-multiline-output "" } */
> +}
> +
> +void surplus_return_when_void_1 (void)
> +{
> +  return 500; /* { dg-error "'return' with a value, in function returning void" } */
> +/* { dg-begin-multiline-output "" }
> +   return 500;
> +          ^~~
> +   { dg-end-multiline-output "" } */
> +/* { dg-begin-multiline-output "" }
> + void surplus_return_when_void_1 (void)
> +      ^~~~~~~~~~~~~~~~~~~~~~~~~~
> +   { dg-end-multiline-output "" } */
> +}
> +
> +void surplus_return_when_void_2 (int i, int j)
> +{
> +  return i * j; /* { dg-error "'return' with a value, in function returning void" } */
> +/* { dg-begin-multiline-output "" }
> +   return i * j;
> +          ~~^~~
> +   { dg-end-multiline-output "" } */
> +/* { dg-begin-multiline-output "" }
> + void surplus_return_when_void_2 (int i, int j)
> +      ^~~~~~~~~~~~~~~~~~~~~~~~~~
> +   { dg-end-multiline-output "" } */
> +}
> +
> +int missing_return_value (void)
> +{
> +  return; /* { dg-error "'return' with no value, in function returning non-void" } */
> +/* { dg-begin-multiline-output "" }
> +   return;
> +   ^~~~~~
> +   { dg-end-multiline-output "" } */
> +/* { dg-begin-multiline-output "" }
> + int missing_return_value (void)
> +     ^~~~~~~~~~~~~~~~~~~~
> +   { dg-end-multiline-output "" } */
> +/* TODO: ideally we'd underline the return type i.e. "int", but that
> +   location isn't captured.  */
> +}
> diff --git a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c
> index 063fdf1f636..b74481b870c 100644
> --- a/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c
> +++ b/gcc/testsuite/gcc.dg/diagnostic-range-bad-return.c
> @@ -1,4 +1,4 @@
> -/* { dg-options "-fdiagnostics-show-caret -Wreturn-local-addr" } */
> +/* { dg-options "-fpermissive -fdiagnostics-show-caret -Wreturn-local-addr" } */
>  
>  int *address_of_local (void)
>  {
> diff --git a/gcc/testsuite/gcc.dg/permerror-default.c b/gcc/testsuite/gcc.dg/permerror-default.c
> index 90f2220037c..9ed9814d69e 100644
> --- a/gcc/testsuite/gcc.dg/permerror-default.c
> +++ b/gcc/testsuite/gcc.dg/permerror-default.c
> @@ -75,11 +75,11 @@ incompatible_pointer_types (int flag)
>  void
>  return_mismatch_1 (void)
>  {
> -  return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */
> +  return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */
>  }
>  
>  int
>  return_mismatch_2 (void)
>  {
> -  return; /* { dg-warning "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */
> +  return; /* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" } */
>  }
> diff --git a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c
> index 0780e42b5cc..dc282a44489 100644
> --- a/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c
> +++ b/gcc/testsuite/gcc.dg/permerror-gnu89-nopermissive.c
> @@ -75,7 +75,7 @@ incompatible_pointer_types (int flag)
>  void
>  return_mismatch_1 (void)
>  {
> -  return 0; /* { dg-warning "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */
> +  return 0; /* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" } */
>  }
>  
>  int
> diff --git a/gcc/testsuite/gcc.dg/permerror-system.c b/gcc/testsuite/gcc.dg/permerror-system.c
> index cad48c93f90..f00420358d9 100644
> --- a/gcc/testsuite/gcc.dg/permerror-system.c
> +++ b/gcc/testsuite/gcc.dg/permerror-system.c
> @@ -27,3 +27,6 @@
>  /* { dg-error "initialization of 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 45 } */
>  /* { dg-error "assignment to 'int \\\*' from 'int' makes pointer from integer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 46 } */
>  /* { dg-error "returning 'int \\\*' from a function with return type 'int' makes integer from pointer without a cast \\\[-Wint-conversion\\\]" "" { target *-*-* } 48 } */
> +
> +/* { dg-error "'return' with a value, in function returning void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 78 } */
> +/* { dg-error "return' with no value, in function returning non-void \\\[-Wreturn-mismatch\\\]" "" { target *-*-* } 84 } */

You may want to use 'return' here too (as in, add the leading ').

> diff --git a/gcc/testsuite/gcc.dg/pr105635-2.c b/gcc/testsuite/gcc.dg/pr105635-2.c
> index 807eef0b7cd..019dbc7e557 100644
> --- a/gcc/testsuite/gcc.dg/pr105635-2.c
> +++ b/gcc/testsuite/gcc.dg/pr105635-2.c
> @@ -7,5 +7,5 @@ void foo (int, int[*]);	/* { dg-message "previous declaration of 'foo' with type
>  foo (int x, int y)	/* { dg-error "return type defaults to 'int'" } */
>  {			/* { dg-warning "conflicting types for 'foo'" "" { target *-*-* } .-1 } */
>  			/* { dg-message "declared here" "" { target *-*-* } .-2 } */
> -  return (x >= 0) != (y < 0);	/* { dg-warning "'return' with a value, in function returning void" } */
> +  return (x >= 0) != (y < 0);	/* { dg-error "'return' with a value, in function returning void" } */
>  }
> diff --git a/gcc/testsuite/gcc.dg/pr23075-2.c b/gcc/testsuite/gcc.dg/pr23075-2.c
> new file mode 100644
> index 00000000000..0702ddf1a66
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr23075-2.c
> @@ -0,0 +1,14 @@
> +/* PR c/23075 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -Wreturn-type" } */
> +
> +int
> +foo (void)
> +{
> +  return;	/* { dg-error "with no value" } */
> +}		/* { dg-bogus "control reaches end" } */
> +
> +int
> +bar (void)
> +{
> +}		/* { dg-warning "control reaches end" } */
> diff --git a/gcc/testsuite/gcc.dg/pr23075.c b/gcc/testsuite/gcc.dg/pr23075.c
> index 2d85fb0650f..28baf41006a 100644
> --- a/gcc/testsuite/gcc.dg/pr23075.c
> +++ b/gcc/testsuite/gcc.dg/pr23075.c
> @@ -1,6 +1,6 @@
>  /* PR c/23075 */
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -Wreturn-type" } */
> +/* { dg-options "-O2 -fpermissive -Wreturn-type" } */
>  
>  int
>  foo (void)
> diff --git a/gcc/testsuite/gcc.dg/pr29521-a.c b/gcc/testsuite/gcc.dg/pr29521-a.c
> new file mode 100644
> index 00000000000..2c6a48b7e30
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr29521-a.c
> @@ -0,0 +1,15 @@
> +/* PR 29521 : warning for return with expression in function returning void */
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +void func (void) { }
> +
> +void func2 (void)
> +{
> +  return func ();
> +}
> +
> +void func3 (void)
> +{
> +  return 1;  /* { dg-error "'return' with a value" } */
> +}
> diff --git a/gcc/testsuite/gcc.dg/pr29521.c b/gcc/testsuite/gcc.dg/pr29521.c
> index b6fb535fab7..cd431514ed2 100644
> --- a/gcc/testsuite/gcc.dg/pr29521.c
> +++ b/gcc/testsuite/gcc.dg/pr29521.c
> @@ -1,6 +1,6 @@
>  /* PR 29521 : warning for return with expression in function returning void */
>  /* { dg-do compile } */
> -/* { dg-options "" } */
> +/* { dg-options "-fpermissive" } */
>  
>  void func (void) { }
>  
> diff --git a/gcc/testsuite/gcc.dg/pr67730-a.c b/gcc/testsuite/gcc.dg/pr67730-a.c
> new file mode 100644
> index 00000000000..08737cc9811
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr67730-a.c
> @@ -0,0 +1,11 @@
> +/* PR c/67730 */
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +#include <stddef.h>
> +
> +void
> +fn1 (void)
> +{
> +  return NULL; /* { dg-error "10:.return. with a value" } */
> +}
> diff --git a/gcc/testsuite/gcc.dg/pr67730.c b/gcc/testsuite/gcc.dg/pr67730.c
> index 54d73a62cf8..cc51858c531 100644
> --- a/gcc/testsuite/gcc.dg/pr67730.c
> +++ b/gcc/testsuite/gcc.dg/pr67730.c
> @@ -1,6 +1,6 @@
>  /* PR c/67730 */
>  /* { dg-do compile } */
> -/* { dg-options "" } */
> +/* { dg-options "-fpermissive" } */
>  
>  #include <stddef.h>
>  
> diff --git a/gcc/testsuite/gcc.target/powerpc/conditional-return.c b/gcc/testsuite/gcc.target/powerpc/conditional-return.c
> index 6b3ef5f52ca..c6491216752 100644
> --- a/gcc/testsuite/gcc.target/powerpc/conditional-return.c
> +++ b/gcc/testsuite/gcc.target/powerpc/conditional-return.c
> @@ -1,7 +1,7 @@
>  /* Check that a conditional return is used.  */
>  
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -w" } */
> +/* { dg-options "-O2 -fpermissive -w" } */
>  
>  /* { dg-final { scan-assembler {\mbeqlr\M} } } */
>  

These seem fine.

Should we have a test for -Wno-error=return-mismatch and -Wno-return-mismatch?
I didn't see those.

Marek


  reply	other threads:[~2023-11-23 17:32 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
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 [this message]
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=ZV+Mu183fSDb2P3R@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).