From patchwork Wed Jan 26 17:49:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 50460 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 72380383D807 for ; Wed, 26 Jan 2022 17:50:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72380383D807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643219420; bh=p0h/pjkIWlOipiq5EQlXKyGUaeFpWtBQSgBe8NyhGQ4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xUzqoi9iIMnXktJ6M/iQkjwrn14dIXxqm7Cbq6+Iluez8Mp1u1XjaVlxrdgMogbvv ZepNCnl504eUS08gA8s2D2xf5w+y/FlKU62KRiv55YgH5tWxv4Zn2Clf2aJqNrXdJd lSgwn6otYZ0uszFL+tNxpkHJZgHY9JOEJ7/1bhtM= 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 ESMTPS id 445F4383E82E for ; Wed, 26 Jan 2022 17:49:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 445F4383E82E 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-471-ZOKFQTINOIiVjwe00qahEg-1; Wed, 26 Jan 2022 12:49:23 -0500 X-MC-Unique: ZOKFQTINOIiVjwe00qahEg-1 Received: by mail-qv1-f72.google.com with SMTP id eo11-20020ad4594b000000b0042151b7180aso549661qvb.8 for ; Wed, 26 Jan 2022 09:49:23 -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=p0h/pjkIWlOipiq5EQlXKyGUaeFpWtBQSgBe8NyhGQ4=; b=unbx1D1EldYT3+mQZwzV35M5CnXwx0mUBhV1HwvjE5OwJwjDXtqyFcmta5neVdVTwq B8MiJkRrmnwuqk8vMxBZNfKU5N7CDYnPUuluJFviS9zJmSSAJt8lrqoVywdxlUcFZvW1 un5v0cmBHu7b3tJ72RlQd7gfdSHlLAVBQLFAveHV/RjjcXaFzN+v4UULJOdeeF0yWhRU IQ5n4vvUNIXTcuEzl+qzbxa4y14/Ky6arK9/4XsfAx2k7vehHIFs5lRX7iUhTXmKgaKu 41fPwWBLuwYWSjIbwtLyO4fc+3HihXPm7mll+KYxKPbEddKGIocDzbqIQgvy+ueS1o2p DARQ== X-Gm-Message-State: AOAM533CzPRipAZchhrN9r5WN4324hSB15iwBiucGSiYNoAurEXofWzS vG8bVZedbKcIlDdfUEljp1SD9DCTB2+jmGs0uVP5aY5nx8g0VMxZkBTVS01+Ys3adMH480vqW+t WmMy6lESaLTWYwfKRqoiaC0wczk3Z1P8FL8vFcj7RSNBmkTI0Y5HASO00EpLpTI+u3HY= X-Received: by 2002:a37:c206:: with SMTP id i6mr5751135qkm.256.1643219362496; Wed, 26 Jan 2022 09:49:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLyuwWl5qW0bLJQZOPdfRrzK4NNvVadOB7hiyEG2/6dNS0Q9lfsR51OEbrs4nNY0sl42Pcgg== X-Received: by 2002:a37:c206:: with SMTP id i6mr5751106qkm.256.1643219362024; Wed, 26 Jan 2022 09:49:22 -0800 (PST) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id f21sm1358819qtk.38.2022.01.26.09.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 09:49:21 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: constrained partial spec using qualified name [PR92944] Date: Wed, 26 Jan 2022 12:49:19 -0500 Message-Id: <20220126174919.2775070-1-ppalka@redhat.com> X-Mailer: git-send-email 2.35.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.4 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" In the nested_name_specifier branch within cp_parser_class_head, we need to update TYPE with the result of maybe_process_partial_specialization just like we do in the template_id_p branch. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/92944 gcc/cp/ChangeLog: * parser.cc (cp_parser_class_head): Update TYPE with the result of maybe_process_partial_specialization in the nested_name_specifier branch too. Refactor nearby code to accomodate that maybe_process_partial_specialization returns a _TYPE, not a TYPE_DECL, and eliminate local variable CLASS_TYPE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-partial-spec10.C: New test. --- gcc/cp/parser.cc | 18 +++++++----------- .../g++.dg/cpp2a/concepts-partial-spec10.C | 6 ++++++ 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index ed219d79dc9..aa1768ffab1 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -26534,7 +26534,7 @@ cp_parser_class_head (cp_parser* parser, } else if (nested_name_specifier) { - tree class_type; + type = TREE_TYPE (type); /* Given: @@ -26544,31 +26544,27 @@ cp_parser_class_head (cp_parser* parser, we will get a TYPENAME_TYPE when processing the definition of `S::T'. We need to resolve it to the actual type before we try to define it. */ - if (TREE_CODE (TREE_TYPE (type)) == TYPENAME_TYPE) + if (TREE_CODE (type) == TYPENAME_TYPE) { - class_type = resolve_typename_type (TREE_TYPE (type), - /*only_current_p=*/false); - if (TREE_CODE (class_type) != TYPENAME_TYPE) - type = TYPE_NAME (class_type); - else + type = resolve_typename_type (type, /*only_current_p=*/false); + if (TREE_CODE (type) == TYPENAME_TYPE) { cp_parser_error (parser, "could not resolve typename type"); type = error_mark_node; } } - if (maybe_process_partial_specialization (TREE_TYPE (type)) - == error_mark_node) + type = maybe_process_partial_specialization (type); + if (type == error_mark_node) { type = NULL_TREE; goto done; } - class_type = current_class_type; /* Enter the scope indicated by the nested-name-specifier. */ pushed_scope = push_scope (nested_name_specifier); /* Get the canonical version of this type. */ - type = TYPE_MAIN_DECL (TREE_TYPE (type)); + type = TYPE_MAIN_DECL (type); /* Call push_template_decl if it seems like we should be defining a template either from the template headers or the type we're defining, so that we diagnose both extra and missing headers. */ diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C new file mode 100644 index 00000000000..8504a055ac5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-partial-spec10.C @@ -0,0 +1,6 @@ +// PR c++/92944 +// { dg-do compile { target c++20 } } + +namespace ns { template struct A { }; } +template requires true struct ns::A { }; +template requires false struct ns::A { };