From patchwork Mon Jan 29 17:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1892434 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=QaU/7G6I; 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 4TNwZz6HXzz1yQ0 for ; Tue, 30 Jan 2024 04:41:31 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8645E3858431 for ; Mon, 29 Jan 2024 17:41:29 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id D463E3858407 for ; Mon, 29 Jan 2024 17:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D463E3858407 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 D463E3858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706550015; cv=none; b=UMNUhnqceDTYNEqjjtflmV7f5V3wuyf3vcA5/NX04cJtuxZVnoM7HkOTGRJSpaUYJdtzSwO+LagvMpbaq6KIEbxaxHgZYlAIh80MvVRVLl0XOXKJGTtD1tqUsKllNyJW3UZYQQzwF4yPLen16MljaHbvHHG6HbOat4BH/fnJEIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706550015; c=relaxed/simple; bh=pJYrL4OjocKzLIgDkQBXabKGfu3uyaUfkExSJNHe/7o=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=bG3j03v2j7/NnkXO3Jg/lK8JVQqxQ+i/C7uCI4w4DVGuAHO7sdjMYMz89/SflXcPwpJ7yadOBjNt1qpyIBzbZL+xGFky5tCcO5Hrt3AJ0Pz8gckp7PIkos2OnB+taYZknW7oWcBnT3/+AK3pm8lNq7PdQxAHc+r3+x+Z2D3z18A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706550012; 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=owxn5sFAMyRt/2Gp+i1B30GNqsZb9MsKFdGje46dNW4=; b=QaU/7G6IXCFLC7t4e9xZninH+M65VuWcwvSEk260+5KL3gNEXB3eLb36ryxbc8j1928/mP wxkQhh8dU8eCpcAURXUBVjsMh+O5l34pZpj71P6FHzdUaAs/AjjEeP513qPIejpwCFYcVt dCnhGBav2lCEK8KIOz90/RZ6ws8qALo= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-KeX16G6NP4e9pOgsH0ttLg-1; Mon, 29 Jan 2024 12:40:08 -0500 X-MC-Unique: KeX16G6NP4e9pOgsH0ttLg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7831ed4bb2aso579683085a.0 for ; Mon, 29 Jan 2024 09:40:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706550007; x=1707154807; 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=owxn5sFAMyRt/2Gp+i1B30GNqsZb9MsKFdGje46dNW4=; b=fDzK1H+zhz1dKacjadcTziChXFIFqjmirfHjdG1UqXo+883wG1o3F6fHeQ1AvNv42Q 1m300waQ0bDVOE7CspYN9YAHSHVAkjlO1PJzBH7rmDX63rxO2aZYVPAu9uOLiQyoEUg+ itiWafGViIG+30Qf9c8WPtnfM8/cOjDIp7dpnBZ5JBvIbFg+UfWCFqbKVM+H5XaadDuk NlXFfc3iYUfbFQt31NtBImmXrdspVF+ol976UddglfmirNQQVYdRNEisDGAPcmiqQqnz u3HIqZz6Fzb3BHi0jnttfY9cEGyBkHBUepfRL0L2FD0E3KyHpUxBpLt36qfacdJDcdyz mzyg== X-Gm-Message-State: AOJu0YxaZDXw6eBkx5n2OppNo2AWjwo7Scc97moLeEJhzeqWcBgs5wBD m9gjPWAr5HbQeXns6Z4VMSiz3kAKPqNfAB12058I51m6580VNmdCXq1kdueNix44Mh1agMRoYGY sUvxcgNfhTvRVnfxjpq9gM9TKY6jluNOr5lD5G04DpLc8x+ybSyEDEbZEx3/V1Mudk678dQbdwb 3CaQWafKoLmc1J5GSnzjvrgN9j6UVzaFoH644= X-Received: by 2002:a05:620a:d5a:b0:783:e10e:8950 with SMTP id o26-20020a05620a0d5a00b00783e10e8950mr5213234qkl.9.1706550007219; Mon, 29 Jan 2024 09:40:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+xXVgjNhZW/WwKaFpGe9p+jHRxIajFAOt5/0FAdnzLAfanPHUALMOnwYNKdd3DjITJoVEJA== X-Received: by 2002:a05:620a:d5a:b0:783:e10e:8950 with SMTP id o26-20020a05620a0d5a00b00783e10e8950mr5213217qkl.9.1706550006843; Mon, 29 Jan 2024 09:40:06 -0800 (PST) Received: from jason.cygnus.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 s14-20020a05620a16ae00b0078199077d0asm1483092qkj.125.2024.01.29.09.40.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 09:40:06 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: local class in generic lambda [PR113544] Date: Mon, 29 Jan 2024 12:40:03 -0500 Message-Id: <20240129174003.1933807-1-jason@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 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, 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- My earlier commit r14-278-gd60cbbfaa9a3ad was a start toward better handling of local classes in generic lambdas, but isn't actually useful by itself and breaks this testcase, so let's revert it for now. PR c++/113544 gcc/cp/ChangeLog: * pt.cc (instantiate_class_template): Don't partially instantiate. (tsubst_stmt): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp1y/lambda-generic-nested3.C: New test. --- gcc/cp/pt.cc | 14 +++++--------- .../g++.dg/cpp1y/lambda-generic-nested3.C | 11 +++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C base-commit: f3fdaa3eecd155dbdc78c1ec9a259dfa4e379ea4 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index f5bf159a879..fb2448a26e9 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -12226,8 +12226,7 @@ instantiate_class_template (tree type) return error_mark_node; if (COMPLETE_OR_OPEN_TYPE_P (type) - || (uses_template_parms (type) - && !TYPE_FUNCTION_SCOPE_P (type))) + || uses_template_parms (type)) return type; /* Figure out which template is being instantiated. */ @@ -18893,7 +18892,10 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) case TAG_DEFN: tmp = tsubst (TREE_TYPE (t), args, complain, NULL_TREE); - if (CLASS_TYPE_P (tmp)) + if (dependent_type_p (tmp)) + /* This is a partial instantiation, try again when full. */ + add_stmt (build_min (TAG_DEFN, tmp)); + else if (CLASS_TYPE_P (tmp)) { /* Local classes are not independent templates; they are instantiated along with their containing function. And this @@ -18902,12 +18904,6 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl) /* Closures are handled by the LAMBDA_EXPR. */ gcc_assert (!LAMBDA_TYPE_P (TREE_TYPE (t))); complete_type (tmp); - if (dependent_type_p (tmp)) - { - /* This is a partial instantiation, try again when full. */ - add_stmt (build_min (TAG_DEFN, tmp)); - break; - } tree save_ccp = current_class_ptr; tree save_ccr = current_class_ref; for (tree fld = TYPE_FIELDS (tmp); fld; fld = DECL_CHAIN (fld)) diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C new file mode 100644 index 00000000000..27655274a87 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C @@ -0,0 +1,11 @@ +// PR c++/113544 +// { dg-do compile { target c++14 } } + +template +void f() { + [](auto parm) { + struct type : decltype(parm) { }; + }; +} + +template void f();