public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH v2] c: Add -Wreturn-mismatch warning, split from -Wreturn-type
Date: Wed, 08 Nov 2023 08:15:56 +0100	[thread overview]
Message-ID: <87fs1gaf6b.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <8734y523et.fsf@oldenburg.str.redhat.com> (Florian Weimer's message of "Fri, 20 Oct 2023 08:50:34 +0200")

* Florian Weimer:

> The existing -Wreturn-type option covers both constraint violations
> (which are mandatory to diagnose) and warnings that have known
> false positives.  The new -Wreturn-mismatch warning is only about
> the constraint violations (missing or extra return expressions),
> and should eventually be turned into a permerror.
>
> The -std=gnu89 test cases show that by default, we do not warn for
> return; in a function not returning void.  This matches previous
> practice for -Wreturn-type.
>
> gcc/c-family/
>
> 	* c.opt (Wreturn-mismatch): New.
>
> gcc/c/
>
> 	* c-typeck.cc (c_finish_return): Use pedwarn with
> 	OPT_Wreturn_mismatch for missing/extra return expressions.
>
> gcc/
>
> 	* doc/invoke.texi (Warning Options): Document
> 	-Wreturn-mismatch.  Update -Wreturn-type documentation.
>
> gcc/testsuite/
>
> 	* gcc.dg/Wreturn-mismatch-1.c: New.
> 	* gcc.dg/Wreturn-mismatch-2.c: New.
> 	* gcc.dg/Wreturn-mismatch-3.c: New.
> 	* gcc.dg/Wreturn-mismatch-4.c: New.
> 	* gcc.dg/Wreturn-mismatch-5.c: New.
> 	* gcc.dg/Wreturn-mismatch-6.c: New.
> 	* gcc.dg/noncompile/pr55976-1.c: Change -Werror=return-type
> 	to -Werror=return-mismatch.
> 	* gcc.dg/noncompile/pr55976-2.c: Likewise.
>
> ---
> v2: Update comment in gcc.dg/noncompile/pr55976-2.c.  Do not produce
>     an error in C90 pedantic-error mode for return; in a function
>     returning non-void.  Add gcc.dg/Wreturn-mismatch-6.c to demonstrate
>     this behavior.

Ping?  Original patch:

<https://inbox.sourceware.org/gcc-patches/8734y523et.fsf@oldenburg.str.redhat.com/>

Thanks,
Florian


  reply	other threads:[~2023-11-08  7:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20  6:50 Florian Weimer
2023-11-08  7:15 ` Florian Weimer [this message]
2023-11-08 18:10   ` Joseph Myers

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=87fs1gaf6b.fsf@oldenburg.str.redhat.com \
    --to=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).