From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6DE82385782D for ; Fri, 16 Feb 2024 22:15:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DE82385782D 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 6DE82385782D 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=1708121741; cv=none; b=JNCNoaMXzJXH2NULlit5OoKvz27EDntllS7CxvVEBfwQAZKysRUgpw1s0SpBQqfUu0tahMSNjnmcgDjwaNIybxdhlPl8Smq8XkWTQ1PGJdWnbo/KemimGrp6Vf0rStKaUoSLLF8DtnJ4W/iv1x6CJLqGeBOtjdnFZ4T0yCfUipE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708121741; c=relaxed/simple; bh=DUfIUJ3wxaDqYLX9GUuy3MxBHlJKjbqIQ54icPWhjPk=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=mfqAj7tWHwc7SwMxPoMKQozI1gr15G/OiFCoIJr5eZRM4ocIoLnfG2Ezsuw5Ylj0QVBz2MhQleKNCZA98LqYkwGKMr5Z5nzMzqrsuG6PyHJlQ3YjW44qi2UiufpLpnOM8Zm2Z6CJSjEp1nnBYGwBZMsxQnoJl3w/LBacY572Zn0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708121738; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=dmhZDYybkQspb0bwgQVqXxv5LSCM/Whk5is4dPWxLZA=; b=GWQji7QDabBd1SOuElWarlWHPVrk/Vt/f3/elUzb4TSWRnw8qbcXm0sGhHk05aC1nOoNZU AAKB8Qmi95v90C04kOSjaGRSNq0rE6Z2C5V1ztuXt1Qx54jfLzdZb7VuyZmcjnJwo0Vd8t o4EndWUfw0gVNYIDLqEthJP98TMoo0Y= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-304-bErWixyFPL2-v4_DpCTf6A-1; Fri, 16 Feb 2024 17:15:36 -0500 X-MC-Unique: bErWixyFPL2-v4_DpCTf6A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 43946280A9A5 for ; Fri, 16 Feb 2024 22:15:36 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06607492BE2; Fri, 16 Feb 2024 22:15:35 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 41GMFXOh446154 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 16 Feb 2024 23:15:34 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41GMFXr3446112; Fri, 16 Feb 2024 23:15:33 +0100 Date: Fri, 16 Feb 2024 23:15:32 +0100 From: Jakub Jelinek To: Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: Fix up parameter pack diagnostics on xobj vs. varargs functions [PR113802] Message-ID: Reply-To: Jakub Jelinek References: <76a12c05-670d-4c56-8d5a-60cdbba32f84@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: On Fri, Feb 16, 2024 at 10:47:47PM +0100, Jakub Jelinek wrote: > The following patch works. Or yet another option would be instead of (sometimes) clearing declarator->parameter_pack_p when we diagnose this bug for error recovery ignore the this specifier. With the following patch (testsuite patch remains the same), I get excess errors though: /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:30:25: error: expansion pattern 'Selves' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:42:26: error: expansion pattern 'Selves' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:56:26: error: expansion pattern 'Selves&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:68:27: error: expansion pattern 'Selves&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:82:27: error: expansion pattern 'Selves&&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:94:28: error: expansion pattern 'Selves&&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:108:32: error: expansion pattern 'const Selves&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:120:33: error: expansion pattern 'const Selves&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:134:33: error: expansion pattern 'const Selves&&' contains no parameter packs /usr/src/gcc/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics3.C:146:34: error: expansion pattern 'const Selves&&' contains no parameter packs though, that is e.g. on struct S0 { template void g(this Selves... selves) {} // { dg-error "an explicit object parameter cannot be a function parameter pack" } } where such an extra error would have been emitted if the this keyword was omitted. --- gcc/cp/parser.cc.jj 2024-02-16 17:38:27.802845433 +0100 +++ gcc/cp/parser.cc 2024-02-16 23:08:40.835437740 +0100 @@ -25734,22 +25734,6 @@ cp_parser_parameter_declaration (cp_pars decl_specifiers.locations[ds_this] = 0; } - if (xobj_param_p - && ((declarator && declarator->parameter_pack_p) - || cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS))) - { - location_t xobj_param - = make_location (decl_specifiers.locations[ds_this], - decl_spec_token_start->location, - input_location); - error_at (xobj_param, - "an explicit object parameter cannot " - "be a function parameter pack"); - /* Suppress errors that occur down the line. */ - if (declarator) - declarator->parameter_pack_p = false; - } - /* If a function parameter pack was specified and an implicit template parameter was introduced during cp_parser_parameter_declaration, change any implicit parameters introduced into packs. */ @@ -25762,9 +25746,10 @@ cp_parser_parameter_declaration (cp_pars (INNERMOST_TEMPLATE_PARMS (current_template_parms)); if (latest_template_parm_idx != template_parm_idx) - decl_specifiers.type = convert_generic_types_to_packs - (decl_specifiers.type, - template_parm_idx, latest_template_parm_idx); + decl_specifiers.type + = convert_generic_types_to_packs (decl_specifiers.type, + template_parm_idx, + latest_template_parm_idx); } if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) @@ -25794,6 +25779,21 @@ cp_parser_parameter_declaration (cp_pars } } + if (xobj_param_p + && (declarator ? declarator->parameter_pack_p + : PACK_EXPANSION_P (decl_specifiers.type))) + { + location_t xobj_param + = make_location (decl_specifiers.locations[ds_this], + decl_spec_token_start->location, + input_location); + error_at (xobj_param, + "an explicit object parameter cannot " + "be a function parameter pack"); + xobj_param_p = false; + decl_specifiers.locations[ds_this] = 0; + } + /* The restriction on defining new types applies only to the type of the parameter, not to the default argument. */ parser->type_definition_forbidden_message = saved_message; Jakub