From patchwork Wed Nov 22 17:26:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 168491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1501792vqb; Wed, 22 Nov 2023 09:53:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/jK3JvKHOuzN2aeydlyJMjJAgMVwxvxensnYM33+uu3x02F5FzZT4RRYYNbDWNlN1s+7j X-Received: by 2002:ad4:5dcc:0:b0:66d:6526:d605 with SMTP id m12-20020ad45dcc000000b0066d6526d605mr2875932qvh.63.1700675581859; Wed, 22 Nov 2023 09:53:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700675581; cv=pass; d=google.com; s=arc-20160816; b=I+lw/dJhNEhkEM1bIAPYakx6bAeXSinThi081XF5KsI6tOhXkP0zh+i21u7yEAMdQV BHemMF4FPFgHGPu+Y1GsvGtpSphnCuUZuXa26s2CfnahzpVbWpGZz4Kxi+qzraSktJ/w SatimSDrtNyJF1kAXoEWimbmTpjp7xa/ESiUnawYEBeEiGGzcfWVgRJ2Jr6ZnnfjM6Hc SZ4T3GsPKzltJxKBrbxeM/bVKJbs8HW1PObcVFBn2Mf5/Bur0zs5I2zCEslIXfxYjvi7 TUWaYHkMIk/g8gEJk+bLjKMNwEjXt1mTlqEH61HKKhvY720vvEzJ+a3MA+3QYLSfOkYI m/lQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=yxtG9bNvfekcQizIY3gX6HS04qB/CJqNeWWIO4/98Eg=; fh=1Hi9m88IqcWZGtfSxUrMGG+GBgL26N02X1SANXM6iTs=; b=PH+ad1aCZstXhNl7/VyBFrvXwpM86tjal7C6xxOvrj0zYL618o97QvIkY9G9FSpE57 eitLt1wZJJq1L+jWjGAY/A7JTAYWv0Q9gYTbX+qNDEVHqt2dFlHAifnYWiz0Z7ofui5/ G00NWBgmFRDzGyL4VODhVp6dRgQBXYnath4e+F0h9l3BxMetmGe1sLXozvVpGYrwYCDr P3QMLll3DGjRn6nggQYDqCFYZhmwAmAtuWfgX/aYOXQcbFoV8lzpA4ryodUEuTzyytI4 Pw20P4aubbpkLw82TPhisqiVckKgwtkJUI0hUAnfQc8YDO9xkpWvAXWJbUxc+0hwepQZ BieQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rwd1GFf1; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m1-20020ad44a01000000b0066d17e5f450si11516071qvz.30.2023.11.22.09.53.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 09:53:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Rwd1GFf1; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C16C13858414 for ; Wed, 22 Nov 2023 17:30:53 +0000 (GMT) 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 D001F3858298 for ; Wed, 22 Nov 2023 17:30:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D001F3858298 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D001F3858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700674228; cv=none; b=KFU8sm60VHDpJuv0xDhbB+5fwChzIDQJRXVPSYqTYpzfd2Cq7oqs3yhES0jUJBkgCgZp95B1X0Rp5ot+i64j1LHqnJ5atDkhrrT9JyISpf7Lim1q7kH/FgkYL24ZmMpow2fYmgeNx7+LRvklbF9gkZisuJHZAqTsWBPmdX0J6dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700674228; c=relaxed/simple; bh=dYPlSxlqwlRXq7wZnaqlbrG+3x/Ao+bRiAE3Sdw64uQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=q5dc8oQ6uLkD9SgFwD/pUc616P1FdijJ3WLgrFQBccU6y0ScAgyrdLH7SA7grBw0d7ECADXKceYZhYvwz33J713iXHxlLoehghz1S6Q/EcKImExHsnQsEvNzSa7sd/DOmAmtY2pzK/vFO91b8iOayTx4HR/qgxFJQ111yS5tWZU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700674217; 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=yxtG9bNvfekcQizIY3gX6HS04qB/CJqNeWWIO4/98Eg=; b=Rwd1GFf1Z/XI6sFEkbcNj4g9ul19kgfYp5fgS9HX6kYvq6pP3KdAb1IYUqGX5iw/ZOsE+R FtdFgTAdpyGYypFNKlO9dp8ceeeK1wvVxcELOrpdpv+kFYEODCZW67w0HDmqZb/y9xK0m4 uIPc8wxeohLyyL0K8/+ucUD0TlS5Ris= 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-571-aGQyV9GWOzaiQzuylNIzGQ-1; Wed, 22 Nov 2023 12:27:02 -0500 X-MC-Unique: aGQyV9GWOzaiQzuylNIzGQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-77d61aad519so150130885a.2 for ; Wed, 22 Nov 2023 09:27:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700674021; x=1701278821; 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=yxtG9bNvfekcQizIY3gX6HS04qB/CJqNeWWIO4/98Eg=; b=ocdS4ONJ5xTiYg28JWJNXV6lQN6b+FbA4ZlN+Aa7H55bt38+TRFkwdln0E4yC3H88j BasaVXoRtg8DX2f67z0Ag/JEZTv0Iyx0ayA4q8bNfqVcXR9iRQz4HW9HWE5tsqb37Mi7 Cu8wX0R+b8UTMyoEt5pZPRGz34RO1SPP7yL4q1XqkPAR4Qg0BTrYGUHlySF9quBIzPMq PvGnU43kNmJWs661DjgxhZuXw2CiWCcT8dERlyfmOBisx3X+pxyeYys5OvjVrdez4UyL MXvAR1qJu+AO4GI1DzaktyrCupdQQNlLePH9otROJAzp/6Dd2Bt35t2Ik+SuwVB4hIw4 tHkQ== X-Gm-Message-State: AOJu0YwABFwoXUmzHKAd6nnNb2ZYhn+xvdDhmUn1P019CrK1J6bzD+zE v0yHKXtTlYzM0NTfkEt8RqPurMwFDUKlLZu8t78TDzu6N4iehzlNR3WbAOfzIUlIM1R0jkPV8Po ToKARC9qNAvx6xV39R9LWRhsXzdHmhjwRyFIgw2PYJJuUyQROVmGXqbl791RHoK6fAkRUFwp2pS 4= X-Received: by 2002:a05:620a:1707:b0:77b:b1d2:955f with SMTP id az7-20020a05620a170700b0077bb1d2955fmr3686260qkb.4.1700674020792; Wed, 22 Nov 2023 09:27:00 -0800 (PST) X-Received: by 2002:a05:620a:1707:b0:77b:b1d2:955f with SMTP id az7-20020a05620a170700b0077bb1d2955fmr3686231qkb.4.1700674020427; Wed, 22 Nov 2023 09:27:00 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id bs35-20020a05620a472300b0076f12fcb0easm27805qkb.2.2023.11.22.09.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 09:26:59 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: alias template of non-template class [PR112633] Date: Wed, 22 Nov 2023 12:26:57 -0500 Message-ID: <20231122172657.542419-1-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.rc1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783287598826824651 X-GMAIL-MSGID: 1783287598826824651 Bootstrapped and regtested on x86-64-pc-linux-gnu, does this look OK for trunk/13? -- >8 -- The entering_scope adjustment in tsubst_aggr_type assumes if an alias is dependent, then so is the aliased type (and therefore it has template info) but that's not true for the dependent alias template specialization ty1 below which aliases the non-template class A. PR c++/112633 gcc/cp/ChangeLog: * pt.cc (tsubst_aggr_type): Handle empty TYPE_TEMPLATE_INFO in the entering_scope adjustment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-75.C: New test. --- gcc/cp/pt.cc | 1 + gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ed681afb5d4..68ce4a87372 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13976,6 +13976,7 @@ tsubst_aggr_type (tree t, if (entering_scope && CLASS_TYPE_P (t) && dependent_type_p (t) + && TYPE_TEMPLATE_INFO (t) && TYPE_CANONICAL (t) == TREE_TYPE (TYPE_TI_TEMPLATE (t))) t = TYPE_CANONICAL (t); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C new file mode 100644 index 00000000000..1a73a99856e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C @@ -0,0 +1,13 @@ +// PR c++/112633 +// { dg-do compile { target c++11 } } + +struct A { using type = void; }; + +template +using ty1 = A; + +template +using ty2 = typename ty1::type; + +template +ty2 f();