From patchwork Thu May 16 15:32:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1936047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jJToH+hm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgDdT3Lx5z20KF for ; Fri, 17 May 2024 01:33:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12739384AB72 for ; Thu, 16 May 2024 15:33:30 +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 15D083858D20 for ; Thu, 16 May 2024 15:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15D083858D20 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 15D083858D20 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=1715873590; cv=none; b=YnyFAo7EuBOBmlNiRe7ruYl+N3i/o4Ofu9uAj3dm9ZzomNz35OEBz1j/MFCq2QhXGeQIU0LfBxBrrxj9J76oku9YhhqyzayRnNJ1qyw9YFAbqMGSb39pucOXBEnFBO0w7i4E6kPDPRZtGAh0vKX/21XAzQLJ7zR8qZVeD6IhKnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715873590; c=relaxed/simple; bh=kyWF+TkGQUgS/V0AKKKVUSW6tPOn8Sjl5oPL7Rqyxmk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ZnQm7DA/OzZSx3XUgyExhdz/th8iogbaUX5TBKrSrpevt/FQD8OkwqZnL4LO+SNNm1y2hfwxaElNv1IGgD8P3VQys2r//qVJ9hzLc2P+AM+ZiSB9gpxWkv81S6ZVagVfW/0rnumOGAzbjyl7ZEy61x6dAK/NTV4JEmh5y1lAXJ4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715873579; 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=Vc8Pis+fKoExphBllLJPwLnSZeBhTQSKLgbgn//QDYA=; b=jJToH+hmM4aCZ6NxoSW5Nrm77FKzivwsyjbnV8/rnaW4/dBwRjAtHNUc/69lB9YEKlbpRf CpbL9M79u20m1uj5+uNeg/7rQPgU83EwFBwrwCWJpaafJBiuNK8qeRrEDz9kF0/SsJNu5f SCKMD3H+qm91bqcIplMG0krQ0dnreYY= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-388-KMj1mpUxNHq-uP2TM-Oa5Q-1; Thu, 16 May 2024 11:32:58 -0400 X-MC-Unique: KMj1mpUxNHq-uP2TM-Oa5Q-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-43e0e0dab52so97690231cf.1 for ; Thu, 16 May 2024 08:32:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715873575; x=1716478375; 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=Vc8Pis+fKoExphBllLJPwLnSZeBhTQSKLgbgn//QDYA=; b=jlhWBiksqCcrPZtM4bknkdZkbmoGZGfC0vb9yzfASUxxUN9tpI+0YpeZ6mLPZNwxzT FQToFyNJ0/OAD3eIDvMQi8ZxpRKsCS1fkoEy1qUsfJ33yTaq488DZu0aLakCKFm/rTY5 LbAH3gCOQwPbDZwgUx4MKo+INVtv+s8tEkGToiRYTGMXPVJustQ7lWd+10CmVqYCJpfE 4ltaTA+TLB8RnCewsDzNB1W4oWfdCFB0yR2vod0KYu7fSIDDN4/AUzF/Q4PylmoTa9WF kXD+aNB3dvz0cQXlj27Q4QB8cbqbnRJqFdrqH1FxrLbvixElxyHxWCzwHTqTUpE1E04R y62w== X-Gm-Message-State: AOJu0YxQw0BAR28ooH6HpYDyA5Og7FQEapA8cQ1+mtroU1x2Er3nrWOI XObqrgKIkuZLRI4M+kQiTYpF4xlx54WY5R5iY1/aQGNiGmJBWLWp/yay+kBoV+x2bslRiVO8F7q 0GsJ9h9qB4GN4t0FKhDExbGOnby6yVxj1sbDIgTm6p+YSJyMw2FEGfAOLCfS3J4/gtK6xwswarp GEKkwCzr1Md/sWSLjsjZ70/LpcLHRqYtuRy3rf X-Received: by 2002:a05:622a:1988:b0:439:baf4:619a with SMTP id d75a77b69052e-43dec29796emr411487491cf.22.1715873575323; Thu, 16 May 2024 08:32:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGX5+YEwgSofXazWZZa/ztwTJTzF3T6RLG3YvxsngVtMfcWMr645Q5DCdw+PESaIWt3BB3EfQ== X-Received: by 2002:a05:622a:1988:b0:439:baf4:619a with SMTP id d75a77b69052e-43dec29796emr411486821cf.22.1715873574795; Thu, 16 May 2024 08:32:54 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43e144a98a2sm60500761cf.16.2024.05.16.08.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:32:54 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: paren aggr CTAD with base classes [PR115114] Date: Thu, 16 May 2024 11:32:52 -0400 Message-ID: <20240516153252.709681-1-ppalka@redhat.com> X-Mailer: git-send-email 2.45.1.190.g19fe900cfc MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 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_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk and perhaps 14? -- >8 -- We're accidentally ignoring base classes during parenthesized aggregate CTAD because the TYPE_FIELDS of a template type doesn't contain bases, so we need to consider them separately. PR c++/115114 gcc/cp/ChangeLog: * pt.cc (maybe_aggr_guide): Consider base classes in the paren init case. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-aggr15.C: New test. --- gcc/cp/pt.cc | 7 ++++++ .../g++.dg/cpp2a/class-deduction-aggr15.C | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d83f530ac8d..54d74989903 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30202,6 +30202,13 @@ maybe_aggr_guide (tree tmpl, tree init, vec *args) else if (TREE_CODE (init) == TREE_LIST) { int len = list_length (init); + for (tree binfo : BINFO_BASE_BINFOS (TYPE_BINFO (template_type))) + { + if (!len) + break; + parms = tree_cons (NULL_TREE, BINFO_TYPE (binfo), parms); + --len; + } for (tree field = TYPE_FIELDS (template_type); len; --len, field = DECL_CHAIN (field)) diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C new file mode 100644 index 00000000000..16dc0f52b64 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr15.C @@ -0,0 +1,23 @@ +// PR c++/115114 +// { dg-do compile { target c++20 } } + +struct X {} x; +struct Y {} y; + +template +struct A : T { + U m; +}; + +using ty1 = decltype(A{x, 42}); // OK +using ty1 = decltype(A(x, 42)); // OK, used to fail +using ty1 = A; + +template +struct B : T, V { + U m = 42; +}; + +using ty2 = decltype(B{x, y}); // OK +using ty2 = decltype(B(x, y)); // OK, used to fail +using ty2 = B;