From patchwork Fri Sep 3 15:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1524367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=QAgaYrFt; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H1Lsw1FhKz9sPf for ; Sat, 4 Sep 2021 01:13:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8D7DB384842E for ; Fri, 3 Sep 2021 15:13:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D7DB384842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630682032; bh=9Ii843BBYYG3RG51mCZSJrY+FsxL8aMXo0XFQSjTvZ4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QAgaYrFtdkIcXOYgk07hGwZ2vQAg/dyiGdhSvXKsW8S97LYU71kBFdb6RIL6j0Lsw VJPbKvAoLORCIkiIogkksCL7I+v9swkhoe0B1mwirIs8574c+M+NoVFCe+HqTgVZOg Y8Nv+PPup2R/wUAj5BSseyTKTHlVuZquz7sW+58g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id E31C1384B13A for ; Fri, 3 Sep 2021 15:13:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E31C1384B13A Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-MWZOtGnsOFOcfx7SPt7Vlg-1; Fri, 03 Sep 2021 11:13:09 -0400 X-MC-Unique: MWZOtGnsOFOcfx7SPt7Vlg-1 Received: by mail-qk1-f200.google.com with SMTP id g73-20020a379d4c000000b003d3ed03ca28so6174972qke.23 for ; Fri, 03 Sep 2021 08:13:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=9Ii843BBYYG3RG51mCZSJrY+FsxL8aMXo0XFQSjTvZ4=; b=t33lYGZ5IMNL8abDwhDJD9ce3sWgFDSQqBOyyzYOc/tDUMlh0VOE0NtObw0XShYK8L p4begJCg9zvhmUQ/IGQ8gsNMWf5lXN4rGbhJT2n6CIh2cI6gvcO1ldtIwkJzP7O7yjVG sCn0CdvCP2lsdWwbTaYPlZmpttglmQgeWy9ci5pDyYyF7MWX74DHTDHMRF3EqYHltVrf DQZlyESS4QeS15XbdoeBU5H3J62K9bfTt4ekIIdEWxs6S/37K/Ztt35At4m8pBTFooKb nyyVBRzttQyQEx6T5Xmfj+HbIqh6h5F7MjVzeK8YemWgQZsL1Yx3nIs54YZU9+m66fnd hBGw== X-Gm-Message-State: AOAM5310Nm0rTqYPd/gFnA/MYk2A1uZExctyErRS087U6zFUg3j6dX/W Y9yV8f9ZvITV7/f44qKnEQpO5ZjBi/y1CxynIzEvd3/JHMNjFWU7HLnPW9cpTRMBnl8JvNjO40j YNjQZZ6Wz9mXovvtXSlLKrXB5hX5XylHxh6kw/EKmCdsxRgv+GaSahNEnvWOlk4+8Ww== X-Received: by 2002:ac8:5710:: with SMTP id 16mr1343301qtw.393.1630681988405; Fri, 03 Sep 2021 08:13:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2/qCL+S2tB0sIfcOnmqTzDx6968leVWDMEE1xM834+2+q+doWYDUNEFgG8nX26G+/ZYmCDw== X-Received: by 2002:ac8:5710:: with SMTP id 16mr1343269qtw.393.1630681987966; Fri, 03 Sep 2021 08:13:07 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s11817.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id s20sm3110088qtw.14.2021.09.03.08.13.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 08:13:07 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: Avoid bogus -Wunused with recent change Date: Fri, 3 Sep 2021 11:13:05 -0400 Message-Id: <20210903151305.1208497-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" My change to make limit_bad_template_recursion avoid instantiating members of erroneous classes produced a bogus "used but not defined" warning for 23_containers/unordered_set/instantiation_neg.cc; it's not defined because we decided not to instantiate it. So we need to suppress that warning. Tested x86_64-pc-linux-gnu, applying to trunk. gcc/cp/ChangeLog: * pt.c (limit_bad_template_recursion): Suppress -Wunused for decls we decide not to instantiate. --- gcc/cp/pt.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) base-commit: 943c65c4494145e993af43c821c82000013c6375 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 72b22d8c487..1b81501386b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10890,15 +10890,27 @@ limit_bad_template_recursion (tree decl) return false; /* Avoid instantiating members of an ill-formed class. */ - if (DECL_CLASS_SCOPE_P (decl) - && CLASSTYPE_ERRONEOUS (DECL_CONTEXT (decl))) - return true; + bool refuse + = (DECL_CLASS_SCOPE_P (decl) + && CLASSTYPE_ERRONEOUS (DECL_CONTEXT (decl))); - for (; lev; lev = lev->next) - if (neglectable_inst_p (lev->maybe_get_node ())) - break; + if (!refuse) + { + for (; lev; lev = lev->next) + if (neglectable_inst_p (lev->maybe_get_node ())) + break; + refuse = (lev && errs > lev->errors); + } - return (lev && errs > lev->errors); + if (refuse) + { + /* Don't warn about it not being defined. */ + suppress_warning (decl, OPT_Wunused); + tree clone; + FOR_EACH_CLONE (clone, decl) + suppress_warning (clone, OPT_Wunused); + } + return refuse; } static int tinst_depth;