From patchwork Tue Oct 22 21:56:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 2000676 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=YUx72z/B; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4XY5cc2tS5z1xtp for ; Wed, 23 Oct 2024 08:57:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52ADB385841F for ; Tue, 22 Oct 2024 21:57:02 +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 ESMTP id 77D483858C42 for ; Tue, 22 Oct 2024 21:56:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77D483858C42 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 77D483858C42 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=1729634205; cv=none; b=LV47FqNifeRxonY+xOeTZNsZzL8wMpW9vojSzHSyL5KE3MnaTvS4WjHu3zydhVgPCretSBkmgt0lolZ0NUjmpgGJdvnuxTgjxlihGQjb0u2jghDfk557HfWLGwZ3jSQIx/5MQhdyRpHAS/WH8Yhf9cvn/WDZzAr4zETuneND5FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729634205; c=relaxed/simple; bh=WAZK2WSrPV/IUv0GK/hIqRjHZsiOsVWScI8HUWgFLMw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VXIPyqy0a30XgMYMlTizJWypMtpAFkqjX0LPVo6MIYEerIMMt96aEFHVNEgMUcutTlAKwBWwnYXWcsyU2LcZ8bNdzK5MIhH+qOoAjfQaYJKqSdsTctgkyUe1VKuMjDASAw9m+AN7arqSXanJuAPV44PbB2LFkRA326DqHms0U/k= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729634203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zre0liG5yZNBf3F3ypyI8F34P6KkuRi5jcHbZsmRkpk=; b=YUx72z/BGxQAyZjYXxZNaP9fhHnAn0Wa4maAyAgZsWqYLS7/jFBng6ggpwjNTuG6jPg8wF U6zAYf+aOipEFgU391JDq6uOR2PRbV60SrXIogjh+V/0WeN1oE2vs7/a4170ImGwk0DHeu mAyrXMqjTO5IhDJuhfURl1Nb900W26s= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-26-H4cY5g7PM8qZ0XzNOugEvA-1; Tue, 22 Oct 2024 17:56:40 -0400 X-MC-Unique: H4cY5g7PM8qZ0XzNOugEvA-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-6e370d76c15so115359567b3.2 for ; Tue, 22 Oct 2024 14:56:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729634199; x=1730238999; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zre0liG5yZNBf3F3ypyI8F34P6KkuRi5jcHbZsmRkpk=; b=wY5yuRZPdNCcDCorIKkcH2YB2eOWsLrbURD9OWpWy8MRuEWbeeLPeA2xTwDIzOPcLd yyzu2dxagU2tPouUXng7OhTmkFrt5NgRFPLG/D5do3QwGG4xIiDxUlebxo3EASSt4Nlq j561zwgxIkQtGZnK+XJFYQiUuHKf4gHZrC49vSpyEpI/wIg8f/vNsbL3Jmt9YxuoEKO2 8zdGoFFRD7/e/GxhvhuPRIpS10IZxJz5AUoVYIQzrqaFaXqyksKsxSqvRGrirvJRQXAt tZ0xWuFK2ITx9m0c8TIuEKInQeB2ONVQtDO6yIpfbdZvRm6qHKFD4o+trYI5HQ6XAzIH ymnQ== X-Gm-Message-State: AOJu0YwibQXy+n+cdJYA9mC326Hje4n0nD1quPoExJ46vNWjGfPIoaDH RkqZslnn5NDxZaqWjzkQPBGUloDTYUpB4P1YYmVrdcBOqbU7wPUwWKfbkCcqyA0ij7hxiOfMKp3 wr/n2bIJ9XrfF6d2JCLUwb6sH8zP/a3MOhgPY+bj2E4MtOiP2MIp9E7G2WA5HhFXjgcCuyw/9Hq VU5pKWE1NI7wpdVeWb4xcO/lN6IlVy+7C09TA= X-Received: by 2002:a05:6902:12c4:b0:e28:7d2e:bb6d with SMTP id 3f1490d57ef6-e2e3a6e1d59mr440783276.54.1729634199309; Tue, 22 Oct 2024 14:56:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/nJyR4He70VW+YMVUqSQSBpX5pSS5KBncV931pQTjU9lMb7pQ8qXUZobXGdgaD/DDnjik+A== X-Received: by 2002:a05:6902:12c4:b0:e28:7d2e:bb6d with SMTP id 3f1490d57ef6-e2e3a6e1d59mr440764276.54.1729634198923; Tue, 22 Oct 2024 14:56:38 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-460d3da210csm33977061cf.81.2024.10.22.14.56.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 14:56:38 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: non-dep structured binding decltype again [PR117107] Date: Tue, 22 Oct 2024 17:56:29 -0400 Message-ID: <20241022215637.2120456-1-jason@redhat.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 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 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 Tested x86_64-pc-linux-gnu, applying to trunk and 14. -- 8< -- The patch for PR92687 handled the usual case of a decomp variable not being in the table, but missed the case of there being nothing in the table yet. PR c++/117107 PR c++/92687 gcc/cp/ChangeLog: * decl.cc (lookup_decomp_type): Handle null table. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/decomp10.C: New test. --- gcc/cp/decl.cc | 5 +++-- gcc/testsuite/g++.dg/cpp2a/decomp10.C | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/decomp10.C base-commit: f191c8301545658543773ba3d0e6f3f0927529e0 prerequisite-patch-id: fea7085e225c97bf6ef676d9a628cc9abe9ae3cb diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 7281818be8f..354b224fd6b 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -9446,8 +9446,9 @@ static GTY((cache)) decl_tree_cache_map *decomp_type_table; tree lookup_decomp_type (tree v) { - if (tree *slot = decomp_type_table->get (v)) - return *slot; + if (decomp_type_table) + if (tree *slot = decomp_type_table->get (v)) + return *slot; return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/cpp2a/decomp10.C b/gcc/testsuite/g++.dg/cpp2a/decomp10.C new file mode 100644 index 00000000000..8fe425b5d01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/decomp10.C @@ -0,0 +1,21 @@ +// PR c++/117107 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template +constexpr bool is_same = false; // { dg-warning "variable template" "" { target c++11_down } } +template +constexpr bool is_same = true; // { dg-warning "variable template" "" { target c++11_down } } + +struct tuple { + template + void check_tuple_like() { + tuple t; + auto [v, r] = t; // { dg-warning "structured bindings" "" { target c++14_down } } + (void)[v, r] { // { dg-warning "captured structured" "" { target c++17_down } } + decltype(v) x; + }; + } + int a = 0; + int &b = a; +};