From patchwork Tue Jan 18 16:08:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 50163 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70597385801F for ; Tue, 18 Jan 2022 16:09:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70597385801F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642522140; bh=QPbsDUuYy7iCPwi+lIhIszgqMbNdmynoA68GTq8TTYM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Zp6osDxNYmslqxyKt+9I1fR4d14/w7sy89Lob4zBRGusReAVAg38TVhwhXOXpe6fy Y4WGk9tx9zgtWKbE4r7vaUQzy+ldbnNcJD4j+P7OA/KRgFHpiFw0X29W0xLIwbE9sd X9qE9K7l6BiY18sr7zVQ0zIaHvQogwYb1ZUvfLzk= 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 9C5B33858D28 for ; Tue, 18 Jan 2022 16:08:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C5B33858D28 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-xWYjQ5OAMyOhcIFmdodQXQ-1; Tue, 18 Jan 2022 11:08:30 -0500 X-MC-Unique: xWYjQ5OAMyOhcIFmdodQXQ-1 Received: by mail-qk1-f198.google.com with SMTP id q5-20020a05620a0d8500b004738c1b48beso16194918qkl.7 for ; Tue, 18 Jan 2022 08:08:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QPbsDUuYy7iCPwi+lIhIszgqMbNdmynoA68GTq8TTYM=; b=Ql/V9HtVL+yvpEqE3i5pmyFNJqjqZmMU/XUFuNe2VFzUcOsKfn4G0Fq2fUe0D4/7dU HlSBB/YY3vo2R7U5bE9nn3nBfZUmkD/cV0WSN93YrqT7JE3C7YDt1aDOIru6NGspJeZw hlsFh9HLb/EVWsTCpq0NC7UuvW9CMOiC4T2t4fdCzkQ+AfpayZaDzy8pSa3fR9pS+Cu4 SFo3EVT2WrvNTyn39qnO/47xdlHewTmE06aVkYI/Vh05cOqjVDmQncfY0dwGZsOpZfif fXq/NFQslRheUWuoyDdqJB8aBjVrhT+AtVOe85HpI3udO1hVWBAwS+f767LghO1kcqNg YpqQ== X-Gm-Message-State: AOAM531ckUbBqEI47jwoha4RSz9iKHwFl1Dvw92DRPk8l0yaAC4VO0Lk 1uz9nQDuJeXaI/uyo+OcfG6Gaue5jNjbbDMw6ERQfLwg1elTUJ8nffSXHeCUmbhxVfXGkIQQ1M6 TccqOdyLeaO2Y46RTLeRdPrU9ZZh5pP/mnHkt6TsodlneIDVRUR7YSl+5tPWZSciXc8U= X-Received: by 2002:a05:620a:f10:: with SMTP id v16mr18643195qkl.36.1642522109043; Tue, 18 Jan 2022 08:08:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNepEG2MqoyzvSWB8hhnL0nc2G4G4qrs+Y9c49xclIEByAcGa1MuWepYsTMJMWeSaGzwRZDA== X-Received: by 2002:a05:620a:f10:: with SMTP id v16mr18643172qkl.36.1642522108759; Tue, 18 Jan 2022 08:08:28 -0800 (PST) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id t6sm8378463qtr.28.2022.01.18.08.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 08:08:27 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: DEPENDENT_OPERATOR_TYPE as type of NTTP [PR104074] Date: Tue, 18 Jan 2022 11:08:25 -0500 Message-Id: <20220118160825.246989-1-ppalka@redhat.com> X-Mailer: git-send-email 2.35.0.rc1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" We're incorrectly rejecting the below testcase during template argument coercion because invalid_nontype_parm_type_p returns true for DEPENDENT_OPERATOR_TYPE. This patch fixes this by partially rewriting invalid_nontype_parm_type_p in terms of WILDCARD_TYPE_P, of which DEPENDENT_OPERATOR_TYPE is one. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/104074 gcc/cp/ChangeLog: * pt.c (invalid_nontype_parm_type_p): Use WILDCARD_TYPE_P so that we return false for DEPENDENT_OPERATOR_TYPE too. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/nontype-auto20.C: New test. --- gcc/cp/pt.c | 14 ++++++-------- gcc/testsuite/g++.dg/cpp1z/nontype-auto20.C | 5 +++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/nontype-auto20.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0fa4a162354..e57613488d4 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26931,16 +26931,14 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) } return false; } - else if (TREE_CODE (type) == TYPENAME_TYPE) - return false; - else if (TREE_CODE (type) == DECLTYPE_TYPE) - return false; else if (TREE_CODE (type) == NULLPTR_TYPE) return false; - /* A bound template template parm could later be instantiated to have a valid - nontype parm type via an alias template. */ - else if (cxx_dialect >= cxx11 - && TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) + else if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM + && cxx_dialect < cxx11) + /* Fall through; before C++11 alias templates, a bound ttp + always instantiates to a class type. */; + else if (WILDCARD_TYPE_P (type)) + /* Any other wildcard type not already handled above is allowed. */ return false; else if (TREE_CODE (type) == COMPLEX_TYPE) /* Fall through. */; diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto20.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto20.C new file mode 100644 index 00000000000..03eea91ce09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto20.C @@ -0,0 +1,5 @@ +// PR c++/104074 +// { dg-do compile { target c++17 } } + +template class gr_sp; +template using gr_rp = gr_sp<+T::recycle>;