From patchwork Mon Jun 19 14:15:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 777784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wrtLg2ZcBz9s4s for ; Tue, 20 Jun 2017 00:16:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="x/iTvyh3"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=krj1gROwgHph9NuJuwXSkaVvyALiVdHqxtvYPPe2wGlsdbF6gs CwrkdSFof/27P8ACwgTVURKFd7vwfP86BlqcXN7OzsPemLUlW+PFPAgbmT6LRIJd o06el35z4GWgIhjUrTVOyHHhyTU+nl9CtQtHxBRK2uxujeLvvcHDmTGVA= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=h/p5FYoDdb1HfjW2sVinuB0rAgk=; b=x/iTvyh3jLtctZt7RHhC 85jRUDJKk7gO9ziSVCH8F/Sd+o2Gs18RPNs5QBvQ5SDI5p00f2UaVJaKa4VFLtiI c21wCRW0wl/XpPkQCqK9JX5gEKzH9Yjzsvuo422v0d51Szne8dK6NI7oV6i/mJd3 4auF/TZNFxUDNw7T4JSzsrg= Received: (qmail 27689 invoked by alias); 19 Jun 2017 14:15:56 -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 4966 invoked by uid 89); 19 Jun 2017 14:15:29 -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, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=hiding X-HELO: mail-yb0-f174.google.com Received: from mail-yb0-f174.google.com (HELO mail-yb0-f174.google.com) (209.85.213.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Jun 2017 14:15:27 +0000 Received: by mail-yb0-f174.google.com with SMTP id f192so28373046yba.2 for ; Mon, 19 Jun 2017 07:15:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=rmjESwQ+yr2dcXKmoXsdVUKT6fke0ezC/xYgBeA4tIc=; b=OK3EM+E2yUcAiYt0Bz9GnP1l5luRK2oqMitSh40TD0XZlx1Bj3H9votsoh91h2Wpcm 7J1fRRjllHjqwbcXrpS+1LClnRHafYMn3vrwLyhvL5qdq8fi1L9sLX49Uq0nIrvo0/IN GXUTGwHt36SUujoqQi1HPNahaWkoDpotqiWUMs2qRzotHKwOh2l7Bq4oC79dMDLbXW5u 1zivJAuEklew3UItbC1hN7RabgpXp55QFH+f3t0vfJHTUYmyuExgtG0EFtcL7fX8uzSv N1c36pNF5VXMwMcTQO3g5WEvuOmh+oVx7PnAD/NJOWn1k1gwOs/NuHUobDvuw8EBBbK/ vuYA== X-Gm-Message-State: AKS2vOz/WJLcdfe4w3a5mmbi0SkZi0dKXKAPgMg6RpCHwa+VztAaNkTQ irRljntU2gXZog== X-Received: by 10.37.59.133 with SMTP id i127mr19205970yba.235.1497881728944; Mon, 19 Jun 2017 07:15:28 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::144]) by smtp.googlemail.com with ESMTPSA id x8sm4463062ywj.8.2017.06.19.07.15.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 07:15:28 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/81119] Wshadow regression Message-ID: <1f5333ca-bf85-a78c-f698-e2ece16d39aa@acm.org> Date: Mon, 19 Jun 2017 10:15:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 This fixes pr 81119. My rewriting of name lookup was a little too eager to warn about constructor hiding. This restores the earlier behaviour of only warning when hiding via a function. nathan 2017-06-19 Nathan Sidwell PR c++/81119 * name-lookup.c (update_binding): Only warn about constructors hidden by functions. PR c++/81119 * g++.dg/warn/pr81119.C: New. Index: cp/name-lookup.c =================================================================== --- cp/name-lookup.c (revision 249364) +++ cp/name-lookup.c (working copy) @@ -1784,6 +1784,14 @@ update_binding (cp_binding_level *level, else goto conflict; + if (to_type != old_type + && warn_shadow + && MAYBE_CLASS_TYPE_P (TREE_TYPE (to_type)) + && !(DECL_IN_SYSTEM_HEADER (decl) + && DECL_IN_SYSTEM_HEADER (to_type))) + warning (OPT_Wshadow, "%q#D hides constructor for %q#D", + decl, to_type); + to_val = ovl_insert (decl, old); } else if (!old) @@ -1849,21 +1857,6 @@ update_binding (cp_binding_level *level, add_decl_to_level (level, to_add); } - if (to_type != old_type) - { - gcc_checking_assert (!old_type - && TREE_CODE (to_type) == TYPE_DECL - && DECL_ARTIFICIAL (to_type)); - - tree type = TREE_TYPE (to_type); - if (to_type != decl - && MAYBE_CLASS_TYPE_P (type) && warn_shadow - && (!DECL_IN_SYSTEM_HEADER (decl) - || !DECL_IN_SYSTEM_HEADER (to_type))) - warning (OPT_Wshadow, "%q#D hides constructor for %q#T", - decl, type); - } - if (slot) { if (STAT_HACK_P (*slot)) Index: testsuite/g++.dg/warn/pr81119.C =================================================================== --- testsuite/g++.dg/warn/pr81119.C (nonexistent) +++ testsuite/g++.dg/warn/pr81119.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/81119 Wshadow regression +// { dg-additional-options "-Wshadow" } + +struct A; +typedef A A; // No warning, does not hide + +struct B; // { dg-message "previous" } +typedef int B; // { dg-error "conflicting" } + +struct C; +void C (); // { dg-warning "hides constructor" } +void C (int); // warning not repeated + +struct D; +int D; // no warning, not a function + +struct E; + +enum X + {E}; // no warning, not a function