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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 886853858002 for ; Tue, 30 Mar 2021 20:35:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 886853858002 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-j79KSl78PQWG1XV8N_dP5Q-1; Tue, 30 Mar 2021 16:35:21 -0400 X-MC-Unique: j79KSl78PQWG1XV8N_dP5Q-1 Received: by mail-qv1-f71.google.com with SMTP id b15so13899850qvz.15 for ; Tue, 30 Mar 2021 13:35:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tJOeIW8O7Smw+5xdApEYSZ8N7V9DsYUvaF1Qhj3LASU=; b=kqnluJ19koNpVcAConRlX8Bq79Zd7ZIH2ER5CT9PvaAgso0PCyELXJqtttlJNRm16f rcugbtiMKWLgD0oJCRQfKQdh0YxFfS/xo5sYLrF5ohXWZmxEK9WhKp+hCn/s9K1+lIl8 hcTTXNAtULowSc5UEQ5QPxXVGZAjFXqxzaBmvu9iFrqX77BRfMuWgHqInb4jLsNJkYp6 x43CFBT9aiErZ7RD3VMdYIitZLTcyF4/sf9a9iFskbqBMthSKRjdCH1vu6cFKCppgduO vC47dfmMT/cZvHLv+YeP5ywRdPOOJ11mSZ6VS52AG1zYhDAjJs0JZ+kFMm7HEvzhwiUM /m1Q== X-Gm-Message-State: AOAM532qf//7QTPORqZVmtKN/chynxE9f+PTrR0YbodGJxEaL91+7lxC DsRQ8hchvq9l2R/oY/ndyUQHNzCMw5rHo9MmiwMiupmYm5J7EE7CKV7QMaotJrJa4MHMd1aKyRg hGwZkLRYz2AjRYO03BA+O4LgbzBvzzfQUMXa0hJ4FVHb8iFPFZEJ78YMP0Xxm8NDz3JQ= X-Received: by 2002:a05:622a:110e:: with SMTP id e14mr29500809qty.335.1617136520955; Tue, 30 Mar 2021 13:35:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3Gg7woAB4UY93ODeEm+s9bQ2qrUAoYwgj/Fi4ZCAdkYBpUkrppFA+l/cHripyjUAzBNhKBQ== X-Received: by 2002:a05:622a:110e:: with SMTP id e14mr29500789qty.335.1617136520568; Tue, 30 Mar 2021 13:35:20 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id v11sm46775qtx.79.2021.03.30.13.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 13:35:20 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: placeholder type constraint and argument packs [PR99815] Date: Tue, 30 Mar 2021 16:35:15 -0400 Message-Id: <20210330203515.50901-1-ppalka@redhat.com> X-Mailer: git-send-email 2.31.1.133.g84d06cdc06 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-Spam-Status: No, score=-16.2 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Tue, 30 Mar 2021 20:35:24 -0000 When checking dependence of a placeholder type constraint, if the first template argument of the constraint is an argument pack, we need to expand it so that we properly separate the implicit 'auto' argument from the rest. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? gcc/cp/ChangeLog: PR c++/99815 * pt.c (placeholder_type_constraint_dependent_p): Expand argument packs to separate the first non-pack argument from the rest. gcc/testsuite/ChangeLog: PR c++/99815 * g++.dg/cpp2a/concepts-placeholder5.C: New test. --- gcc/cp/pt.c | 5 +++ .../g++.dg/cpp2a/concepts-placeholder5.C | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder5.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a056ecefd1d..dc6f2f37f9b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -28189,6 +28189,11 @@ placeholder_type_constraint_dependent_p (tree t) tree id = unpack_concept_check (t); tree args = TREE_OPERAND (id, 1); tree first = TREE_VEC_ELT (args, 0); + if (ARGUMENT_PACK_P (first)) + { + args = expand_template_argument_pack (args); + first = TREE_VEC_ELT (args, 0); + } gcc_checking_assert (TREE_CODE (first) == WILDCARD_DECL || is_auto (first)); for (int i = 1; i < TREE_VEC_LENGTH (args); ++i) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder5.C new file mode 100644 index 00000000000..eaea41a36eb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder5.C @@ -0,0 +1,32 @@ +// PR c++/99815 +// { dg-do compile { target c++20 } } + +template +struct is_same { static constexpr bool value = false; }; + +template +struct is_same { static constexpr bool value = true; }; + +template +concept C = is_same::value; // { dg-error "wrong number" } + +template void f() { + C auto x = 0; // { dg-error "constraints" } +} + +template void f(); // { dg-bogus "" } +template void f(); // { dg-message "required from here" } +template void f<>(); // { dg-message "required from here" } +template void f(); // { dg-message "required from here" } + +template void g() { + C auto x = 0; // { dg-error "constraints" } +} + +template void g<>(); // { dg-bogus "" } +template void g(); // { dg-message "required from here" } + +template void h() { + C auto x = 0; // { dg-error "constraints" } + C auto y = 0; +} -- 2.31.1.133.g84d06cdc06