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.129.124]) by sourceware.org (Postfix) with ESMTPS id 0DCB83858C36 for ; Fri, 23 Jun 2023 15:59:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0DCB83858C36 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687535996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IdpijZUgDCu/aSSYtsT8NSYPttl6Lv/3il9hP9l72Lc=; b=f7dOtFr23yW34Pm6INXRxh3dl+KHfdN+fLGvivqYDtuDl3JacMD0RlKRlfpAUTZk2mfurP nC65QBNJwoQY+lxfOjGKP6eaPTy1wKfunIpGcWxkrXxFDgOiSTr7FtROOMqcWUKBYJ0fOw AOPeZG6WmIzBOyxtfgI5BYTY67TXUYs= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-2zHYhTd4PiaTqC3jVXu2Og-1; Fri, 23 Jun 2023 11:59:53 -0400 X-MC-Unique: 2zHYhTd4PiaTqC3jVXu2Og-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-763a397a3ceso85020885a.1 for ; Fri, 23 Jun 2023 08:59:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687535993; x=1690127993; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IdpijZUgDCu/aSSYtsT8NSYPttl6Lv/3il9hP9l72Lc=; b=U7Uu66y+kNLdezhZo36dtW+yXY5+X4bsjheX4ZyXHXI4eAEc1lmdGAjFzeQHJqIP36 S7pZG6rMs6nUYj99Hr50doOQJWPJi2/BcUCWFjfipYBLFfxSMYdRDQM7JTnckHxz0hJ5 JA106ftTyMNvtkUjGKEXayQWkarTAqtCDswMlGI9jD+FfXjHs6p2/qVj7pL8yZzADsAT jH+uOqK74iH1UP4plqwFiTReji7we/tmfkq4pJd0Q6F3QPUTJia2q+7yauUxFx1n5Hs1 fu/hyI/q7qmCA/gtWY7zTNQfzeckH3Go4yTLFmLM4O9ReZL4i7B578rkZLKNQNlj5GA5 K/HA== X-Gm-Message-State: AC+VfDzM27JelH46cwnk2ecfS9N+3yilQsztVyqrVcU3vdL6Fwfcz7sG YE8BDV90E2AWAWI5n54zGBN5HFhNPQfHxBrWj+BOMFVO3ZD/E7ho7ppeI86ejLbZSDxYVhgF40+ sN1Dgrv01Cr/l+I63Gg== X-Received: by 2002:a05:620a:4154:b0:75f:921:3e7b with SMTP id k20-20020a05620a415400b0075f09213e7bmr25499254qko.64.1687535993353; Fri, 23 Jun 2023 08:59:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69dOnJigvnwEeHd2ircTwnLIbvdKtz20vehcfX4sby+eDyVN7wwPieD5vn+FGaKcZlynw2pQ== X-Received: by 2002:a05:620a:4154:b0:75f:921:3e7b with SMTP id k20-20020a05620a415400b0075f09213e7bmr25499239qko.64.1687535993085; Fri, 23 Jun 2023 08:59:53 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id pc21-20020a05620a841500b0075cebaa1540sm4614774qkn.58.2023.06.23.08.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 08:59:52 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Fri, 23 Jun 2023 11:59:51 -0400 (EDT) To: Nathaniel Shead cc: gcc-patches@gcc.gnu.org, jason@redhat.com Subject: Re: [PATCH] c++: Fix ICE with parameter pack of decltype(auto) [PR103497] In-Reply-To: Message-ID: <4c77b9a3-48cb-93c7-1489-38155c637926@idea> References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 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_H5,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: Hi, On Sat, 22 Apr 2023, Nathaniel Shead via Gcc-patches 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. Thanks very much for the patch! Some minor comments below. > > PR 103497 We should include the bug component name when referring to the PR in the commit message (i.e. PR c++/103497) so that upon pushing the patch the post-commit hook automatically adds a comment to the PR reffering to the commit. I could be wrong but AFAIK the hook only performs this when the component name is included. > > 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 > --- > 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 We could check is_auto (type) here instead, to avoid any confusion with checking AUTO_IS_DECLTYPE for a non-auto TEMPLATE_TYPE_PARM. > + && AUTO_IS_DECLTYPE (type)) > + { > + error_at (token->location, > + "cannot declare a parameter with %"); > + 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" } I noticed for void foo(decltype(auto) arg); we already issue an identical error from grokdeclarator. Perhaps we could instead extend the error handling there to detect decltype(auto)... as well, rather than adding new error handling in cp_parser_simple_type_specifier? > + > +int main() { > + foo(); > +} > -- > 2.34.1 > >