From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CB1973858D1E for ; Tue, 2 May 2023 21:14:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB1973858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683062054; 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=WRsfJiZaYYBFS/dusNGH/Z1MaAziiFkZDBGKVOVwdrc=; b=QOgydhdINk0VnTZ49ve57Ze1cGG4EYeuX4ztOC2frOA/L2EW8800eyGTCgqcAu9x85/tIL JvoqaKZS/AOt+296VPBS3nH+1Aj7Op4AOpkV7Lbl6bGpPwbGdA3jGfqxWzteI0X4h9yUax 37DjisWEkYXniKKz8Sl3aNGuVwFJlEo= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-J1ewhlnPPiWcY8IZFQJpVA-1; Tue, 02 May 2023 17:14:13 -0400 X-MC-Unique: J1ewhlnPPiWcY8IZFQJpVA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-74e3f029192so252519385a.0 for ; Tue, 02 May 2023 14:14:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683062052; x=1685654052; 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=WRsfJiZaYYBFS/dusNGH/Z1MaAziiFkZDBGKVOVwdrc=; b=GGtGoGWyrXWKWrBgVPY8Vxb4ZPXfQc2xX1PUVagIzQReD09OuxfFl2Z2uma4y1Y4/N fiRkS66xm4eSGLr/GACTB0UiGLDVxR02FJj1YvAhcngC1tMul5hbmSXKYjS298KFTw2Q wIYNzZdYPfsuSFNxGugqslf3ZsdFreTW77vIyHPMqySZEgYGeWgkkJ/nnQoI0UDpmK6S UPEGa+2oOlQ4xXkZa1zrRuo0UHRp/GtoTJnbLorBJwaYnC2xt3SsZHxXbAvAqQc96ryH 9piyvXfX2zSMpL7GzXW9nCHai8WwryXrTykP7TX57H6LxQcxlVzDwkorcN26RstZmb7s ai8A== X-Gm-Message-State: AC+VfDxn2YVH90Gh92HxNKqbIzjQP7mxIFDAVQlCqONjM1sBXKtcveDh hzLfTANPmSzmTJ5M/jQWr8Aq4BHp9AkDlTs2eCp3vNDoVc8OQBF2ttnyUw+TczE7E5waQMrdp7e wLWpcrMlRpIaPnq7hglqYphIiYQB9UbbYai3eQ2ckYPGxnAB+mj5ocNkOi6z5cGVASM/bTBOsuM E= X-Received: by 2002:ac8:5dd2:0:b0:3f0:a481:c4a1 with SMTP id e18-20020ac85dd2000000b003f0a481c4a1mr27864272qtx.66.1683062052288; Tue, 02 May 2023 14:14:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7EVu3Wdzo3+ekzYWbtrCm/Rm4zxKpOyIrFBXKycDFIqSNkFmSNWPzm9Kh/zyO2lPztt9zPpg== X-Received: by 2002:ac8:5dd2:0:b0:3f0:a481:c4a1 with SMTP id e18-20020ac85dd2000000b003f0a481c4a1mr27864244qtx.66.1683062051971; Tue, 02 May 2023 14:14:11 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id 21-20020ac84e95000000b003ef5dc13bbbsm148091qtp.85.2023.05.02.14.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 14:14:11 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: satisfaction of non-dep member alias template-id Date: Tue, 2 May 2023 17:13:10 -0400 Message-ID: <20230502211310.220156-1-ppalka@redhat.com> X-Mailer: git-send-email 2.40.1.459.g48d89b51b3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.8 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: constraints_satisfied_p already carefully checks dependence of template arguments before proceeding with satisfaction, so the dependence check in instantiate_alias_template is unnecessary and overly conservative. Getting rid of it allows us to check satisfaction ahead of time in more cases as in the below testcase. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/cp/ChangeLog: * pt.cc (instantiate_alias_template): Exit early upon error from coerce_template_parms. Remove dependence test guarding constraints_satisfied_p. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-alias6.C: New test. --- gcc/cp/pt.cc | 6 +++--- gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 3f1cf139bbd..930291917f2 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -22178,11 +22178,11 @@ instantiate_alias_template (tree tmpl, tree args, tsubst_flags_t complain) args = coerce_template_parms (DECL_TEMPLATE_PARMS (tmpl), args, tmpl, complain); + if (args == error_mark_node) + return args; /* FIXME check for satisfaction in check_instantiated_args. */ - if (flag_concepts - && !any_dependent_template_arguments_p (args) - && !constraints_satisfied_p (tmpl, args)) + if (!constraints_satisfied_p (tmpl, args)) { if (complain & tf_error) { diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C new file mode 100644 index 00000000000..4acd57d36e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-alias6.C @@ -0,0 +1,15 @@ +// Verify we can check satisfaction of non-dependent member alias +// template-ids whose constraints don't depend on outer template +// arguments ahead of time. +// { dg-do compile { target c++20 } } + +template +struct A { + template requires (N > 0) + using at = T; + + void f() { + using ty1 = at<0>; // { dg-error "constraint" } + using ty2 = at<1>; + } +}; -- 2.40.1.459.g48d89b51b3