From patchwork Fri Oct 20 20:29:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 156303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1309101vqb; Fri, 20 Oct 2023 13:30:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDlL2H3tOV6ldLpe373YE+auPWUQKP7pIp5KUJHbTTC/iseRes8L9+jFNbS05aK7IGEbJo X-Received: by 2002:a05:6214:262e:b0:66d:a12f:7140 with SMTP id gv14-20020a056214262e00b0066da12f7140mr282827qvb.18.1697833823646; Fri, 20 Oct 2023 13:30:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697833823; cv=pass; d=google.com; s=arc-20160816; b=dGZZLxVIwOeKdeIbKRyLwQnaGPx/ZeR9zzFtzAXb6y+7/XOJ56AOpMJKAPYyv3iUVQ DhDPlmoEDF303HBXEzkyUZ+D+t46TrpVQj87h01YU+iy8qqDb+H4uhAi4zThWVc9XaxZ YzDpfpzZbtmr1ADjAbul5p6WsVEPnrrKfWuuI0eJmY+se3ImND0SoJJHqo+cIGCuVxYr m+kv06CwRITYZphot3lvz0u3iu7O594l7PFgDbs6Ps7/2IeiLu3AkmdlNpvZaPcNtUmB YH6QSHsoaimr2STAVTp57haXYBMJhZ3BcAmNShp0RrYz1WC1cVx74jkHpkvztIvI1Th+ 4Pfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=S1iQ2jZQ97HLqKREwnuifDJMamFjEWlOEmxixfcC4So=; fh=rniJ05hh5TtJEgvFF322qtTpFQcCvp9aWk5OC4T+KQA=; b=NbsZNrJCck6BziLB9FtA+FOEIR0o1kNd8KIoatJ9ZHDMQPEs016Q1UfbPCOLRSyuLj 6hZIWX84pVa6dW7r4PshPaZjoRbvCJx+DARZZy4G62ZOKVJef5QSNZSEZ8ZGEwKqW9Rh WQc6v2xpHfufNumdEXX+QcoPtJ/TA3kFEtUSDf6MCX8Y64cLaiVGwilrTAQoGDnqIOge 77Cts2qJgGqV/W10Dz0nJ5qtfBtRB9gJKLC4XOvuaK5ZWJWenCXkpjDzmRivTrg/qQv9 Q19pdsMUgf39rGDFWwKedIHJVWHTIDAf2fcGBVvXTeR+JUPp11dUcTBYep7V1e0dFsTW UhwA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="XfjC/3v4"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t22-20020ac85896000000b00417b7f7dfb9si1918803qta.228.2023.10.20.13.30.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:30:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="XfjC/3v4"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 636C43858000 for ; Fri, 20 Oct 2023 20:30:23 +0000 (GMT) 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.133.124]) by sourceware.org (Postfix) with ESMTPS id D77743858D35 for ; Fri, 20 Oct 2023 20:29:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D77743858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D77743858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697833801; cv=none; b=nCBX5jdM7+F4Is+e5bazd9XVeKXd6l3fyCs/2kTe4KnsUTF1qohbk8b75mkXKr45359kzUS4XFAbwa3vM07aNUQhyaj8faqZWK4i0Xksn706uN0CPUgfxde/PWb+oEMjm2pLufhNSwYtnPfvWRlqWsjqcKAkRqeyyZKxI2nOkOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697833801; c=relaxed/simple; bh=sBw9YydV1TY5b3L66/qj9GJQs6w0xfvHrAc64/Rk2+E=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QSodyp/P1RMD+B+KCN1b9csQVMq70U+WLi9I4QM73DlhFDk4aFAaczMzRC1LDor0AKihB6/3WKJ3CbOU+2r0EMqbc+OJ2OwB4rVHFs2c+CNHB270/BE03EzH9sObEwQRYr8ynQI3sMuUvX6dcQ+UFBu709LzlQuv2nMCQQeQpYQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697833798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S1iQ2jZQ97HLqKREwnuifDJMamFjEWlOEmxixfcC4So=; b=XfjC/3v44ARQViNUFPHNKuJu1W3UD70ak/gQwRf/8Z/1kPjloMPg0B/I+nYlBpLV6RD7+K Zot9cteTALfezoQ4koHGiqYLJgm7Xe7VMG23SZAWPYDr5uaVzRUPGW68Ayzl9kuF/R5YN2 J9/jeymDMgGZR9GcyJvUaw5N/ySM7XQ= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-u8xw3ZSRM5SfL54TX0DaaA-1; Fri, 20 Oct 2023 16:29:57 -0400 X-MC-Unique: u8xw3ZSRM5SfL54TX0DaaA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-66d0ceb78cbso13248066d6.1 for ; Fri, 20 Oct 2023 13:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697833796; x=1698438596; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S1iQ2jZQ97HLqKREwnuifDJMamFjEWlOEmxixfcC4So=; b=T5yf5TlE5JjgMRi/sBbBghTX22RxEh4/dM7nN9jMta5kvyfMT1MguBfDUNgCD2YOMZ rWK217JpV8RSC3XiuEW7pde7MkwKWtIIksov4468uuGUg33R+SC78bwyBFGIVaTzYTMO N2abAPaVVMyWEaQXCseX0kLsM4WGHgkXlV48jzTNp7oo1PX4j52FV5f0UeeMWIFMevSR Cm+5oWDG0XuAk4GUvXvuPdUmkI/xkeGxTcmkThLCQIMQ8PoiUZ1I4b+xsRdSbCS3BBDt 88/jaTOGaTfpfGJy9zCh/R9Ltj4lxSWEfwLevu70YQHF8w0JglTcFG6BLQHiceG4/YML PEpg== X-Gm-Message-State: AOJu0YxSSN4p7DD1JDyHLvN/HrXPZ8xSxKtKSqwlIiDLDEeW1L2TqFly rvbAbiZx5afv+saQ9eevWBLg5NlTB03yfTgvW23knwZ0aXmWJycCV2VYjMgsU+6obD+HLSjHhKa n7rc+i0Z/a+amS9PKdEEggj7Uaxwh+N/UE0lK80mAY3Wjj0XGmmIneETh9DCF+StoVz1/PJXB6Q == X-Received: by 2002:ad4:5f4d:0:b0:66d:2b0a:bf0f with SMTP id p13-20020ad45f4d000000b0066d2b0abf0fmr3802070qvg.46.1697833796381; Fri, 20 Oct 2023 13:29:56 -0700 (PDT) X-Received: by 2002:ad4:5f4d:0:b0:66d:2b0a:bf0f with SMTP id p13-20020ad45f4d000000b0066d2b0abf0fmr3802055qvg.46.1697833796044; Fri, 20 Oct 2023 13:29:56 -0700 (PDT) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id d12-20020a056214184c00b0065d03eae7a0sm949920qvy.82.2023.10.20.13.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:29:55 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: Patrick Palka Subject: [pushed] c++: fix tourney logic Date: Fri, 20 Oct 2023 16:29:53 -0400 Message-Id: <20231020202953.2247779-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780307799315447119 X-GMAIL-MSGID: 1780307799315447119 Tested x86_64-pc-linux-gnu, applying to trunk. Patrick, sorry I didn't apply this sooner. -- 8< -- In r13-3766 I changed the logic at the end of tourney to avoid redundant comparisons, but the change also meant skipping any less-good matches between the champ_compared_to_predecessor candidate and champ itself. This should not be a correctness issue, since we believe that joust is a partial order. But it can lead to missed warnings, as in this testcase. gcc/cp/ChangeLog: * call.cc (tourney): Only skip champ_compared_to_predecessor. gcc/testsuite/ChangeLog: * g++.dg/warn/Wsign-promo1.C: New test. --- gcc/cp/call.cc | 5 +++-- gcc/testsuite/g++.dg/warn/Wsign-promo1.C | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wsign-promo1.C base-commit: 084addf8a700fab9222d4127ab8524920d0ca481 diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 657eca93d23..a49fde949d5 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -13227,10 +13227,11 @@ tourney (struct z_candidate *candidates, tsubst_flags_t complain) been compared to. */ for (challenger = candidates; - challenger != champ - && challenger != champ_compared_to_predecessor; + challenger != champ; challenger = challenger->next) { + if (challenger == champ_compared_to_predecessor) + continue; fate = joust (champ, challenger, 0, complain); if (fate != 1) return NULL; diff --git a/gcc/testsuite/g++.dg/warn/Wsign-promo1.C b/gcc/testsuite/g++.dg/warn/Wsign-promo1.C new file mode 100644 index 00000000000..51b76eee735 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsign-promo1.C @@ -0,0 +1,15 @@ +// Check that we get joust warnings from comparing the final champ to a +// candidate between it and the previous champ. + +// { dg-additional-options -Wsign-promo } + +struct A { A(int); }; + +enum E { e }; + +int f(int, A); +int f(unsigned, A); +int f(int, int); + +int i = f(e, 42); // { dg-warning "passing 'E'" } +// { dg-warning "in call to 'int f" "" { target *-*-* } .-1 }