From patchwork Wed Mar 22 19:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1759975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.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=fZfkNSCd; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PhdqX174wz247d for ; Thu, 23 Mar 2023 06:30:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8133638515F0 for ; Wed, 22 Mar 2023 19:30:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8133638515F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679513444; bh=iEssKp7xDRFuhSx4dLIF9Ldtvb7TYvGQmF6cxXwY8Ig=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fZfkNSCdbiE5+mqF9POM1qBAG1BzqpRSEOmWdOT0Zbp/v1HX+lVQDhUYaq+xRTfsv cHLaeM6KD8Zd1Qw9lttN7jrzr4p0qgBpccG1qH+4cAM29EWQy6LCsOeLTP7zxPwBJp SgrhXHPn6UnMDsbAgcgJs6M95A6zoBb8/icT0PY8= 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 4A7323858433 for ; Wed, 22 Mar 2023 19:30:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4A7323858433 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-1wv9AveXPVSjrT7iOhxANg-1; Wed, 22 Mar 2023 15:30:22 -0400 X-MC-Unique: 1wv9AveXPVSjrT7iOhxANg-1 Received: by mail-qv1-f72.google.com with SMTP id oo15-20020a056214450f00b005a228adfcefso9897456qvb.2 for ; Wed, 22 Mar 2023 12:30:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679513421; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iEssKp7xDRFuhSx4dLIF9Ldtvb7TYvGQmF6cxXwY8Ig=; b=AcCZ21gwvDI8LNf5eQr5cy01IoEh3aUT7BagIFp42l/ZMQ+EfCxX2tpZaqbje8HT45 czzb+6gSBhp92N1JyqoapI8qp4gv17+pPBne6i7Au3T57mYNLYK3YPRyPUfnr/6Atdus A5wb6fNpmj/LWYYs4LMCEGaRXv0nN096JWyI+tZ4Unc45HBD6mbXFISK48gAPMjPAq7N AT//KOdPlCqR2OktZt8aPyLc/UNUEpRSB1qVSfDBTAVHv6BbJg9Vm88Q4vsFycSENr1z UHxTO4wlyQRjkZK5Dgf0m/qlsuUXg1zGUHwpgORKEQiwmb7FSvdewCH9od4VCS7mjJTG N9Rg== X-Gm-Message-State: AO0yUKVFdLGpYStDpA7ha3dZgIxtPo04hoKj6S2a1Ml9ydRUll+duk/z UuN6f79AU9+IJaByMmqI8Aoy/vrbT9xraDuoXUkXCOSjFa0pze0WP9u+dalI9UDINtmegs5PosI +Tgb2XekITAkKhN5KzWmL3lbB8pVWjRIscShN6wOAkF5pYMXC5W2KpljkXNvnTNvLlNcIQWQoTQ == X-Received: by 2002:ac8:588c:0:b0:3bf:cff2:2c2f with SMTP id t12-20020ac8588c000000b003bfcff22c2fmr7701994qta.44.1679513421551; Wed, 22 Mar 2023 12:30:21 -0700 (PDT) X-Google-Smtp-Source: AK7set81V6pWMoBToKlEUbjm+HiWHcDVAkrsY6vSWBddJTrXPOhUolYqdg42+cEDZOKQA8pkgBXk7Q== X-Received: by 2002:ac8:588c:0:b0:3bf:cff2:2c2f with SMTP id t12-20020ac8588c000000b003bfcff22c2fmr7701944qta.44.1679513421091; Wed, 22 Mar 2023 12:30:21 -0700 (PDT) Received: from jason.cygnus.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id x23-20020ac87317000000b003b63b8df24asm3988408qto.36.2023.03.22.12.30.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 12:30:20 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: array bound partial ordering [PR108390] Date: Wed, 22 Mar 2023 15:30:16 -0400 Message-Id: <20230322193016.2560128-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 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_H2, 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.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" Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- fold_convert doesn't work with a dependent argument, and problematically differed from the corresponding fold+build_nop further down in the function. So change it to match. PR c++/108390 gcc/cp/ChangeLog: * pt.cc (unify): Use fold of build_nop instead of fold_convert. gcc/testsuite/ChangeLog: * g++.dg/template/partial-order3.C: New test. --- gcc/cp/pt.cc | 8 +++++--- gcc/testsuite/g++.dg/template/partial-order3.C | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/partial-order3.C base-commit: 3e791f45ded89626bc1f9f8013728f6e035801b2 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 056b8c7abad..90bcaa78701 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -24635,8 +24635,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, if ((strict & UNIFY_ALLOW_INTEGER) && TREE_TYPE (targ) && TREE_TYPE (arg) && CP_INTEGRAL_TYPE_P (TREE_TYPE (targ))) - /* We're deducing from an array bound, the type doesn't matter. */ - arg = fold_convert (TREE_TYPE (targ), arg); + /* We're deducing from an array bound, the type doesn't matter. + This conversion should match the one below. */ + arg = fold (build_nop (TREE_TYPE (targ), arg)); int x = !cp_tree_equal (targ, arg); if (x) unify_inconsistency (explain_p, parm, targ, arg); @@ -24684,7 +24685,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, && CP_INTEGRAL_TYPE_P (tparm)) /* Convert the ARG to the type of PARM; the deduced non-type template argument must exactly match the types of the - corresponding parameter. */ + corresponding parameter. This conversion should match the + one above. */ arg = fold (build_nop (tparm, arg)); else if (uses_template_parms (tparm)) { diff --git a/gcc/testsuite/g++.dg/template/partial-order3.C b/gcc/testsuite/g++.dg/template/partial-order3.C new file mode 100644 index 00000000000..154505321bf --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial-order3.C @@ -0,0 +1,6 @@ +// PR c++/108390 +// { dg-do compile { target c++11 } } + +template long f(int(*)[t], T(*)[t]); +template int f(int(*)[i], T(*)[i]) = delete; +int n = f(0, 0);