From patchwork Thu Feb 8 11:22:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 870828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-472832-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CHQjmQ4x"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zcbQm3fngz9s7M for ; Thu, 8 Feb 2018 22:22:55 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:references:to:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=Rm5NvZCKJ3+m9Nt8Q ahA9tjgD6NTKDEPCPwU5x8ET2wplsjBlPn5OGIXiOSqYDRDfvDcxDojWxBAJSsB4 bz+/2SiW8BkmxO7ir5botC6FnAlUQjOS0BKE62WRRHQUPAE9wc7+wx7qgF9pm65a FA5+hETmckILgsfOtiRYojxxak= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:references:to:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=cMZX5u7JG2CFJ01dNGFVeSH Pt0U=; b=CHQjmQ4xiMI0FaYYxL9IcPy+TuYbsdzKj2ys4gzfpvMfq+C84RORJh1 m6r7y1gQG047p0o4fXCevobrPjhipX+bbxjFvNAXDgtSW26JIN+NMiX+knVoHxrd +Fc2UlGHEeH9ST8fDVZ6DgGkMCrVdRJCz2IZLiSrtzCX0kV6oHDY= Received: (qmail 103702 invoked by alias); 8 Feb 2018 11:22:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 103688 invoked by uid 89); 8 Feb 2018 11:22:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Feb 2018 11:22:45 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w18BEvcE074337 for ; Thu, 8 Feb 2018 11:22:44 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2g0ngu01ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 08 Feb 2018 11:22:44 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w18BMh0K007351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 8 Feb 2018 11:22:43 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w18BMfAt032753 for ; Thu, 8 Feb 2018 11:22:43 GMT Received: from [192.168.1.4] (/79.52.198.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 08 Feb 2018 03:22:41 -0800 Subject: Fwd: [C++ Patch] PR 83806 ("[6/7/8 Regression] Spurious -Wunused-but-set-parameter with nullptr") References: To: "gcc-patches@gcc.gnu.org" From: Paolo Carlini X-Forwarded-Message-Id: Message-ID: <215a033c-9cb1-5ddd-56b9-389c1ddb1ae5@oracle.com> Date: Thu, 8 Feb 2018 12:22:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8798 signatures=668663 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802080129 X-IsSubscribed: yes Hi, this one should be rather straightforward. As noticed by Jakub, we started emitting the spurious warning with the fix for c++/69257, which, among other things, fixed decay_conversion wrt mark_rvalue_use and mark_lvalue_use calls. In particular it removed the mark_rvalue_use call at the very beginning of the function, thus now a PARM_DECL with NULLPTR_TYPE as type, being handled specially at the beginning of the function, doesn't get the mark_rvalue_use treatment - which, for example, POINTER_TYPE now gets later. I'm finishing testing on x86_64-linux the below. Ok if it passes? Thanks, Paolo. PS: sorry Jason, I have to re-send separately to the mailing list because some HTML crept in again. Grrr. ///////////////////////// /cp 2018-02-08 Paolo Carlini PR c++/83806 * typeck.c (decay_conversion): Use mark_rvalue_use for the special case of nullptr too. /testsuite 2018-02-08 Paolo Carlini PR c++/83806 * g++.dg/warn/Wunused-parm-11.C: New. Index: testsuite/g++.dg/warn/Wunused-parm-11.C =================================================================== --- testsuite/g++.dg/warn/Wunused-parm-11.C (nonexistent) +++ testsuite/g++.dg/warn/Wunused-parm-11.C (working copy) @@ -0,0 +1,13 @@ +// PR c++/83806 +// { dg-do compile { target c++11 } } +// { dg-options "-Wunused-but-set-parameter" } + +template +bool equals(X x, Y y) { + return (x == y); +} + +int main() { + const char* p = nullptr; + equals(p, nullptr); +} Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 257477) +++ cp/typeck.c (working copy) @@ -2009,7 +2009,10 @@ decay_conversion (tree exp, return error_mark_node; if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp)) - return nullptr_node; + { + exp = mark_rvalue_use (exp, loc, reject_builtin); + return nullptr_node; + } /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue. Leave such NOP_EXPRs, since RHS is being used in non-lvalue context. */