public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathaniel Shead <nathanieloshead@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] c++: Fix ICE with parameter pack of decltype(auto) [PR103497]
Date: Tue, 13 Jun 2023 20:14:00 +1000	[thread overview]
Message-ID: <ZIhBaLMRMbwiB68I@Thaum.localdomain> (raw)
In-Reply-To: <ZEN9yWhVwRqM2kVn@Thaum.localdomain>

(Another) ping.

https://gcc.gnu.org/pipermail/gcc-patches/2023-April/616465.html

On Sat, Apr 22, 2023 at 04:25:13PM +1000, Nathaniel Shead wrote:
> Bootstrapped and tested on x86_64-pc-linux-gnu.
> 
> -- 8< --
> 
> This patch raises an error early when the decltype(auto) specifier is
> used as a parameter of a function. This prevents any issues with an
> unexpected tree type later on when performing the call.
> 
> 	PR 103497
> 
> gcc/cp/ChangeLog:
> 
> 	* parser.cc (cp_parser_simple_type_specifier): Add check for
> 	decltype(auto) as function parameter.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/pr103497.C: New test.
> 
> Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
> ---
>  gcc/cp/parser.cc                | 10 ++++++++++
>  gcc/testsuite/g++.dg/pr103497.C |  7 +++++++
>  2 files changed, 17 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/pr103497.C
> 
> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
> index e5f032f2330..1415e07e152 100644
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -19884,6 +19884,16 @@ cp_parser_simple_type_specifier (cp_parser* parser,
>        && cp_lexer_peek_nth_token (parser->lexer, 2)->type != CPP_SCOPE)
>      {
>        type = saved_checks_value (token->u.tree_check_value);
> +      /* Within a function parameter declaration, decltype(auto) is always an
> +	 error.  */
> +      if (parser->auto_is_implicit_function_template_parm_p
> +	  && TREE_CODE (type) == TEMPLATE_TYPE_PARM
> +	  && AUTO_IS_DECLTYPE (type))
> +	{
> +	  error_at (token->location,
> +		    "cannot declare a parameter with %<decltype(auto)%>");
> +	  type = error_mark_node;
> +	}
>        if (decl_specs)
>  	{
>  	  cp_parser_set_decl_spec_type (decl_specs, type,
> diff --git a/gcc/testsuite/g++.dg/pr103497.C b/gcc/testsuite/g++.dg/pr103497.C
> new file mode 100644
> index 00000000000..bcd421c2907
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr103497.C
> @@ -0,0 +1,7 @@
> +// { dg-do compile { target c++14 } }
> +
> +void foo(decltype(auto)... args);  // { dg-error "parameter with .decltype.auto..|no parameter packs" }
> +
> +int main() {
> +  foo();
> +}
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2023-06-13 10:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22  6:25 Nathaniel Shead
2023-05-27  7:07 ` ping: " Nathaniel Shead
2023-06-13 10:14 ` Nathaniel Shead [this message]
2023-06-23 15:59 ` Patrick Palka
2023-06-24 13:24   ` Nathaniel Shead
2023-06-28 17:54     ` Patrick Palka
2023-06-29 17:43     ` Jason Merrill
2023-06-30  7:05       ` Nathaniel Shead
2023-07-27  3:47         ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZIhBaLMRMbwiB68I@Thaum.localdomain \
    --to=nathanieloshead@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).