On Fri, Jan 12, 2024 at 07:40:19AM +0000, waffl3x wrote:
> Bootstrapped and tested on x86_64-linux with no regressions.
> 
> I'm still getting used to things so let me know if the change log
> entries are excessive, thanks.

> From 9dc168e7bcbbd7d515fa28cb9cae28ec113fae0f Mon Sep 17 00:00:00 2001
> From: Waffl3x <waff...@protonmail.com>
> Date: Thu, 11 Jan 2024 14:32:46 -0700
> Subject: [PATCH] c++: reject packs on xobj params. [PR113307]
> 
> Reject and diagnose xobj parameters declared as parameter packs.
> 
>       PR c++/113307
> 
> gcc/cp/ChangeLog:
> 
>       * parser.cc (cp_parser_parameter_declaration): Reject packs
>       on xobj params.
> 
> gcc/testsuite/ChangeLog:
> 
>       * g++.dg/cpp23/explicit-obj-diagnostics3.C: Add test for
>       rejection of packs.
> 
> Signed-off-by: Waffl3x <waff...@protonmail.com>
> ---
>  gcc/cp/parser.cc                              |  21 +++-
>  .../g++.dg/cpp23/explicit-obj-diagnostics3.C  | 106 +++++++++++++++++-
>  2 files changed, 125 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
> index 8ab98cc0c23..70fbba09bf8 100644
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -25706,6 +25706,25 @@ cp_parser_parameter_declaration (cp_parser *parser,
>       for a C-style variadic function. */
>    token = cp_lexer_peek_token (parser->lexer);
>  
> +  bool const xobj_param_p
> +    = decl_spec_seq_has_spec_p (&decl_specifiers, ds_this);
> +
> +  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");

Formatting - there should be space before ( and the following 2 lines
should be indented accordingly.

Will defer to Jason for the rest.

        Jakub

Reply via email to