From patchwork Fri Nov 8 17:01:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 1192064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512846-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=hotmail.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ct82NPIJ"; 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 478mlf1ql4z9sR4 for ; Sat, 9 Nov 2019 04:02:05 +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:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=EGnnC2dpYj9zvfBBzc8TIgdWl136DlJ6UP93uLm2GTcrPwShagHSu ivifxYYZpQhAD/RrCknxJDWkKWB6rRUthac4g1Bx3017PKa8yEf/OP6NKcEqjIaa 2djkRs15t9SVyYyquQFSq8EjGuEO+xk6xa98UEhoVt3ZsSP/8U9XHQ= 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:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=ATRGFz0N227SCjFCjOKK9uYOhEY=; b=ct82NPIJEot7irQKuHaw FqOTb9pdFcVjdRqgDczSZPNxZV/9EFI08oLSTeOCKb1GDjLUWcp1CD0tiaCFImOC XV7sUgiWs2IEP0py+eZ/UeDxUJZ8WO/WPHyEikAVj8Qk7z7CFIBMZjcP0QGdPZO9 C+/mfmb1MZ/nQCb/a8uG8PI= Received: (qmail 67264 invoked by alias); 8 Nov 2019 17:01:59 -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 67255 invoked by uid 89); 8 Nov 2019 17:01:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-9.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*nathan, H*c:HHH X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-oln040092065042.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.92.65.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2019 17:01:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gl0ZpTb2EZj45m93clEer1m0Hs3YyiZLarB80ZJx5lFg3szaVer4tsaVgZMjj8WlPoHVrwS2Tg8rRm1EOq3NvrcejIIUmKEYBafTm6DbdyNCLXQQXmFdN2P+9gsQ4W2KyHqa2B7TXFap716L/ad/rVKXgZLyG1A7Ebxe4OWg6TtwAs0w1pAq8ONatiu/V1lOuAU/Jtn8uvSziORl9odW3Xqzduf5kWvC1Ra9TRr6raT3F17bDyQQkqeURFPjAkwkf8boCjqD1m57+nquIbUTXBxJ+oZuxvdpLuSljQPkomdProUh+oal1lYb2CJ8ImrBFjcpkifZBpU7IBqsGzRd4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xbfRZsrl5C7enuU098B7XCeil83/U3pWcbconJr7ep0=; b=XDt1tv71Q+DhJZFFf57/3u7xyKJssXL9Zk79e4avUgie9ZOz4yFPLOrWNgK3NaWAvlPVDzPu23QeZQ30uJjsS6RqUyK2FjHtANPhqnT6u2R9WOgij0K7lC2UEUyrP6sJXTlL+Av+lIFBY8yhiNJsKGd3ktWNvkbhqe38XtabToHw9h/olPkGU/dhxpYV0MUvHy7Vu2AZ6mlAjWqV5hTJP++vQwmWBKalcsk/P/qCwLvK7jbv8WobLAyBcAmYlf/4zUHAnpydtcoHTB9FFK4HsnSVKY32jXNC1Byq/0BNOqnQJwSyksHElt4eg2/wZSKZ5wG8RXO0tt+giBk2DF5wDA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from HE1EUR01FT044.eop-EUR01.prod.protection.outlook.com (10.152.0.58) by HE1EUR01HT241.eop-EUR01.prod.protection.outlook.com (10.152.1.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.22; Fri, 8 Nov 2019 17:01:54 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com (10.152.0.60) by HE1EUR01FT044.mail.protection.outlook.com (10.152.0.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2430.22 via Frontend Transport; Fri, 8 Nov 2019 17:01:54 +0000 Received: from VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::49b8:a7e6:9f6f:862d]) by VI1PR03MB4528.eurprd03.prod.outlook.com ([fe80::49b8:a7e6:9f6f:862d%3]) with mapi id 15.20.2430.023; Fri, 8 Nov 2019 17:01:54 +0000 From: Bernd Edlinger To: "gcc-patches@gcc.gnu.org" , Jason Merrill , Nathan Sidwell Subject: [PATCH] Fix PR c++/92365 Date: Fri, 8 Nov 2019 17:01:54 +0000 Message-ID: x-microsoft-original-message-id: <09ea3c5d-c640-5ac4-2620-142cf1196331@hotmail.de> x-ms-exchange-transport-forked: True MIME-Version: 1.0 Hi, this fixes an unexprected fallout from my previous patch on the -Wshadow=complatible-local. By using can_convert_arg here, it avoids the issue, that can_convert tries to cast int() to char*, which is a a possible NULL-pointer value in C++98 (but not in C++11). As pointed out in the PR, there are still more issues with can_convert, but I would like to fix the regression here without digging any deeper in the mud, at least for now. Boot-strapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Thanks Bernd. 2019-11-08 Bernd Edlinger PR c++/92365 * name-lookup.c (check_local_shadow): Use can_convert_arg instead of can_convert. testsuite: 2019-11-08 Bernd Edlinger PR c++/92365 * g++.dg/pr92365.C: New test. Index: gcc/cp/name-lookup.c =================================================================== --- gcc/cp/name-lookup.c (revision 277860) +++ gcc/cp/name-lookup.c (working copy) @@ -2770,8 +2770,8 @@ check_local_shadow (tree decl) (now) doing the shadow checking too early. */ && !type_uses_auto (TREE_TYPE (decl)) - && can_convert (TREE_TYPE (old), TREE_TYPE (decl), - tf_none))) + && can_convert_arg (TREE_TYPE (old), TREE_TYPE (decl), + decl, LOOKUP_IMPLICIT, tf_none))) warning_code = OPT_Wshadow_compatible_local; else warning_code = OPT_Wshadow_local; Index: gcc/testsuite/g++.dg/pr92365.C =================================================================== --- gcc/testsuite/g++.dg/pr92365.C (revision 0) +++ gcc/testsuite/g++.dg/pr92365.C (working copy) @@ -0,0 +1,12 @@ +/* PR c++/92365 */ +/* { dg-options "-std=c++98 -Wshadow=compatible-local" } */ + +class a { +public: + a(char *); +}; +void b() { + a c(0); + if (0) + int c; +}