From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104534 invoked by alias); 2 Jun 2016 10:03:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 104449 invoked by uid 89); 2 Jun 2016 10:03:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=2016-06-02 X-HELO: mail-vk0-f66.google.com Received: from mail-vk0-f66.google.com (HELO mail-vk0-f66.google.com) (209.85.213.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 02 Jun 2016 10:03:21 +0000 Received: by mail-vk0-f66.google.com with SMTP id a6so7564496vkg.1 for ; Thu, 02 Jun 2016 03:03:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=RRBR3ivk3RFdNB7lkcxdEZgJUxThcU5ZGC8q8lnIorE=; b=fCLvR7hvMGW63vbVIzKwVziBCGVwIH0koixSUe7U9aQJf3Cwn5i4LH1/tVadizeAFR BBEYkj3GIGVxpGO2ibcAz5V7FbTtERFi0vVm4XfPfq6jSYBzjvdomjCAiq27djbkdK9t brk6eDZzp15Ud4lIHvv+v5LmBFdTY4hjOc0d4g/U78V3JCRrNtEqzUVH37ZZRqccHyKm SXvwrN1aYdeFiHdSft6iYUBl9GDjrsGz9FMlmtGpABL1fcI6n8B3BGapVKTN/pDak6TR 3KP9/of0fDeCuXffxzXTYb/89SYK3bRU0+CB70CtPPNDxWQqIUsZPOSIvu5grOOkALmv BJEA== X-Gm-Message-State: ALyK8tLGP6iv8uPWnXUHvtmuEt2sPqU3hOLAZ6W71QEIBx1kJP83ZtmY4ypXKV6r+0tO2+Eo+zgDf17Um+gKoA== MIME-Version: 1.0 X-Received: by 10.159.35.207 with SMTP id 73mr4125764uao.13.1464861799040; Thu, 02 Jun 2016 03:03:19 -0700 (PDT) Received: by 10.176.1.65 with HTTP; Thu, 2 Jun 2016 03:03:18 -0700 (PDT) In-Reply-To: <574F9F31.3080203@gmail.com> References: <20160601115504.725560-1-marbacz@gmail.com> <20160601115504.725560-2-marbacz@gmail.com> <20160601120702.GO28550@tucnak.redhat.com> <20160601163915.GU28550@tucnak.redhat.com> <574F155B.6070807@gmail.com> <574F9F31.3080203@gmail.com> Date: Thu, 02 Jun 2016 10:03:00 -0000 Message-ID: Subject: Re: [PATCH] Warn about return with a void expression with -Wreturn-type. From: =?UTF-8?Q?Marcin_Baczy=C5=84ski?= To: Martin Sebor Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-06/txt/msg00135.txt.bz2 2016-06-02 4:51 GMT+02:00 Martin Sebor : >> So here's my shot at fixing this in the documentation. Does that look >> okay? >> > > It looks good to me. Just one minor point below. > >> @@ -4055,8 +4055,12 @@ Warn whenever a function is defined with a >> return type that defaults >> to @code{int}. Also warn about any @code{return} statement with no >> return value in a function whose return type is not @code{void} >> (falling off the end of the function body is considered returning >> -without a value), and about a @code{return} statement with an >> -expression in a function whose return type is @code{void}. >> +without a value). >> + >> +For a @code{return} statement with an expression in a function whose >> +return type is @code{void}, warn unless the expression type is also >> +@code{void}. As a GNU extension, the latter case is accepted without a >> +warning unless @option{-Wpedantic} is used. > > > I would suggest to add that this only applies to C. Otherwise > it's valid C++ so G++ accepts it without a pedantic warning. Done. > > As a disclaimer, someone else endowed with those special powers > will need to approve your final patch. If you don't get a timely > approval please ping the patch weekly. > > Martin > gcc/ChangeLog: PR c/48116. * doc/invoke.texi (-Wreturn-type): Mention not warning on return with a void expression in a void function. --- gcc/doc/invoke.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ce162a0..1747d1b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -4055,8 +4055,12 @@ Warn whenever a function is defined with a return type that defaults to @code{int}. Also warn about any @code{return} statement with no return value in a function whose return type is not @code{void} (falling off the end of the function body is considered returning -without a value), and about a @code{return} statement with an -expression in a function whose return type is @code{void}. +without a value). + +For C only, warn about a @code{return} statement with an expression in a +function whose return type is @code{void}, unless the expression type is +also @code{void}. As a GNU extension, the latter case is accepted +without a warning unless @option{-Wpedantic} is used. For C++, a function without return type always produces a diagnostic message, even when @option{-Wno-return-type} is specified. The only -- 2.8.3