From patchwork Tue Sep 18 13:49:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 971136 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-485882-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dSvmHNJV"; 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 42F4B96TFyz9sD0 for ; Tue, 18 Sep 2018 23:50:09 +1000 (AEST) Received: (qmail 111845 invoked by alias); 18 Sep 2018 13:50:03 -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 111658 invoked by uid 89); 18 Sep 2018 13:49:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:sk:r1-v6mr, H*RU:200, H*r:200, Hx-spam-relays-external:200 X-HELO: mail-yb1-f174.google.com Received: from mail-yb1-f174.google.com (HELO mail-yb1-f174.google.com) (209.85.219.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Sep 2018 13:49:54 +0000 Received: by mail-yb1-f174.google.com with SMTP id 5-v6so828566ybf.3 for ; Tue, 18 Sep 2018 06:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=XbtiFJS4T+/Lj5/8iiP3SFOz2l9dGY2swOnvkdrkiEk=; b=dSvmHNJVI9dCMzSPW4RvWngTzVSWfCHdSMwex+NyxqtHG1GHnNZZmh21zHxI/ERyDU OavEtZf+6RzYtAswibUxi69dluI9zxd2GI2uLKjgXnwsw/+KA+YA6ll2q0KlqGesaKC8 0DxrRww66F+qEotY5uoxCOzh6/fx0aBFesU1pWcnxx5pjrONiiBnSf1M4HFgLmGxCaYX jw/puiJxZBk1ccCD1Dni+Ke9duDaWhuu3OZnvS4eHGhCv2VQfKVW3ZxbQJ+fQPOD0/5m LxetYgkLwF/W0CRh4iWsFBvkPje/+1m500EZoWHWiOuo6BJmP0DYk6yAIl8SrP5+Qxy7 pCjw== Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::34cc]) by smtp.googlemail.com with ESMTPSA id p78-v6sm3254196ywp.31.2018.09.18.06.49.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 06:49:52 -0700 (PDT) Sender: Nathan Sidwell To: GCC Patches From: Nathan Sidwell Subject: [PATCH c++/86881] -Wshadow-local-compatible ICE Message-ID: Date: Tue, 18 Sep 2018 09:49:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 This ICE happens when we try and figure if an unresolved auto type is compatible with a previous binding. With the addition of auto, we're now checking too early, but that's a harder problem. This fixes the ICE, but the downside is we don't warn at all, if the auto resolves to a compatible type. But that's not a new problem. Applying to trunk and gcc-8 nathan 2018-09-18 Nathan Sidwell PR c++/86881 cp/ * name-lookup.c (check_local_shadow): Ignore auto types. testsuite/ * g++.dg/warn/pr86881.C: New. Index: gcc/cp/name-lookup.c =================================================================== --- gcc/cp/name-lookup.c (revision 264371) +++ gcc/cp/name-lookup.c (working copy) @@ -2764,6 +2764,13 @@ check_local_shadow (tree decl) && (same_type_p (TREE_TYPE (old), TREE_TYPE (decl)) || (!dependent_type_p (TREE_TYPE (decl)) && !dependent_type_p (TREE_TYPE (old)) + /* If the new decl uses auto, we don't yet know + its type (the old type cannot be using auto + at this point, without also being + dependent). This is an indication we're + (now) doing the shadow checking too + early. */ + && !type_uses_auto (TREE_TYPE (decl)) && can_convert (TREE_TYPE (old), TREE_TYPE (decl), tf_none)))) warning_code = OPT_Wshadow_compatible_local; Index: gcc/testsuite/g++.dg/warn/pr86881.C =================================================================== --- gcc/testsuite/g++.dg/warn/pr86881.C (revision 0) +++ gcc/testsuite/g++.dg/warn/pr86881.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/86881 ICE with shadow warning +// { dg-do compile { c++11 } } +// { dg-additional-options { -Wshadow-compatible-local } }} + +void a() { + auto b([] {}); + { + auto b = 0; + } +} + +struct Proxy { }; + +void Two () +{ + auto my = Proxy (); + { + auto my = Proxy (); // { dg-warning "shadows" "" { xfail *-*-* } } + }; +}