From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 14:15:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------FD0879B834C004EBFAC6D8A8" X-SW-Source: 2017-06/txt/msg01312.txt.bz2 This is a multi-part message in MIME format. --------------FD0879B834C004EBFAC6D8A8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 217 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 -- Nathan Sidwell --------------FD0879B834C004EBFAC6D8A8 Content-Type: text/x-patch; name="pr81119.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr81119.diff" Content-length: 2053 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 --------------FD0879B834C004EBFAC6D8A8--