From patchwork Fri Jan 24 22:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1229087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518241-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=gaBRyOSz; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hCjlOXqz; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 484DDL3X2zz9sR0 for ; Sat, 25 Jan 2020 09:22:56 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=E4Xn4beMM2ysW5Yo 9sktBPFyb8C7VEKpbFRs5gA0D7ZMZsibuYVN26qHfMjPOeUDiqzEpeN8OkQDOQAh beLm6+C/fDznPghpDoKu5VclVzWqvL+taBToc3HDSs4GXnBTsLtssVKj1zwn8JTG 4eUoILkYvwTMHAnkImFeNUpzDRg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=uoM4rShwmiJUJ40vZ2kJkh KDkzI=; b=gaBRyOSzKM58q0BPXgSEsTYCtygvtI3h33cGcoWHrjLoHwD0KEagoh V1XF3/5GQb9EbH+cEw5t4f6+Atavb/CJiOQKr9W8U+4jDIhK6rGC655Xm8YQgiPn mJTHGsWRnlsDLKeK4bVLel8rTnJw7g/jhLrxMcC4LsxI1aTTmt71Y= Received: (qmail 75246 invoked by alias); 24 Jan 2020 22:22:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 75236 invoked by uid 89); 24 Jan 2020 22:22:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Jan 2020 22:22:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579904565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iw6Ugk7rgg+F12AC90lvNxwB2kz+DIzhj1f4nQCCZoc=; b=hCjlOXqzHREvwl/8s+4NUqhVqS4mpOtCyYj/d/UCg8i2FQw7qK0uHi/9o1im4F9KAl0WB2 BeUtDsJ0GEhAxYrOle98bPC7kermSCKvs5gFIw3cKVh38CZPt9kfZ1x4rSOFWD3b0yDdy/ Mot1+GtTf16znyH6Jt1MDNSb8DUVzKQ= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-75-rtF0zYr3NLasnxvKfS5ZxQ-1; Fri, 24 Jan 2020 17:22:43 -0500 Received: by mail-qv1-f72.google.com with SMTP id e10so2072020qvq.18 for ; Fri, 24 Jan 2020 14:22:43 -0800 (PST) Received: from barrymore.redhat.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id i13sm4026646qkk.78.2020.01.24.14.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2020 14:22:41 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [COMMITTED] c++: Fix parameter map handling of member typedef. Date: Fri, 24 Jan 2020 17:22:40 -0500 Message-Id: <20200124222240.22868-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-IsSubscribed: yes any_template_parm_r was looking at the args of an alias template-id, but we need to look at all args of a member alias/typedef, including implicit ones from the enclosing class. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/93377 - ICE with member alias in constraint. * pt.c (any_template_parm_r): Look at template arguments for all aliases, not only alias templates. --- gcc/cp/pt.c | 20 +++---- gcc/testsuite/g++.dg/cpp2a/concepts-alias5.C | 62 ++++++++++++++++++++ 2 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-alias5.C base-commit: 14e5881e37771f1f58123e77c558adb3b90c8764 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 95719927249..209044135cb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10427,19 +10427,15 @@ any_template_parm_r (tree t, void *data) } \ while (0) + /* A mention of a member alias/typedef is a use of all of its template + arguments, including those from the enclosing class, so we don't use + alias_template_specialization_p here. */ + if (TYPE_P (t) && typedef_variant_p (t)) + if (tree tinfo = TYPE_ALIAS_TEMPLATE_INFO (t)) + WALK_SUBTREE (TI_ARGS (tinfo)); + switch (TREE_CODE (t)) { - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - /* Search for template parameters in type aliases. */ - if (tree ats = alias_template_specialization_p (t, nt_opaque)) - { - tree tinfo = TYPE_ALIAS_TEMPLATE_INFO (ats); - WALK_SUBTREE (TI_ARGS (tinfo)); - } - break; - case TEMPLATE_TYPE_PARM: /* Type constraints of a placeholder type may contain parameters. */ if (is_auto (t)) @@ -10472,6 +10468,8 @@ any_template_parm_r (tree t, void *data) tree cparms = ftpi->ctx_parms; while (TMPL_PARMS_DEPTH (dparms) > ftpi->max_depth) dparms = TREE_CHAIN (dparms); + while (TMPL_PARMS_DEPTH (cparms) > TMPL_PARMS_DEPTH (dparms)) + cparms = TREE_CHAIN (cparms); while (dparms && (TREE_TYPE (TREE_VALUE (dparms)) != TREE_TYPE (TREE_VALUE (cparms)))) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-alias5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-alias5.C new file mode 100644 index 00000000000..907b0c2e357 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-alias5.C @@ -0,0 +1,62 @@ +// PR c++/93377 +// { dg-do compile { target c++2a } } + +struct empty +{}; + +template +c value; + +template +auto func(value); + +template +struct alignment_algorithm; + +template +struct select +{ + template + decltype(algorithm_t()(func<_args_t>...)) choose(); + + template + static empty choose(); + + using type = decltype(choose, args_t...>()); +}; + +template +struct select_algorithm : select +{}; + +template struct maybe_value { int value; }; + +template +struct maybe_value; + +struct function +{ + template >::value)> + function(algorithm_t); +}; + +template +struct alignment_configuration_traits +{ + static constexpr bool is_vectorised = 0; +}; + +template +struct alignment_algorithm +{ + using traits_t = alignment_configuration_traits; + template + void operator()(indexed_sequence_pairs_t) requires traits_t::is_vectorised; +}; + +int main() +{ + function{alignment_algorithm{}}; +}