From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id 745173858D33 for ; Sat, 27 May 2023 07:07:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 745173858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-53f448cde66so1360947a12.1 for ; Sat, 27 May 2023 00:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685171241; x=1687763241; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1wc2AJx0bw632ZN8DFccwxlJTfp1K0hXq+4PX2KHiCo=; b=GmEnQutZzoCF+IVYjR+fcW/uVnlvdLYYnelwmW0O59uaEbprtGAytEu5pVBtYl16Bz 2Zebd4FYIdvTjDWay3b1grC4aLmBxxXQB1Wn3SWIB+6vWSuWr5uA5ubRZX/kvp0YUsFf 4FhlAQPZHNEjUAz6HBHJYFEs0KiITSpekQz5M0vXBoFgxwXie6Q1HFJZgAR5VUtjUVqE Znbym+qAT0gsAyfuwPZP943uKT1dBiEkX4PVTHYp5j37AOhdkswYMQ2VGowGbrN96bsq QQVD5izYBcZSA4+0bVJGa2SuBH1g+09C4cFNPpam6Ry/1Rxp2StkkMbcUGvzIriJrNow d1vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685171241; x=1687763241; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1wc2AJx0bw632ZN8DFccwxlJTfp1K0hXq+4PX2KHiCo=; b=mFfCnhdGQIrXW2RZpdoNJGTA/kxUIuzUibRJIAk/xUfFAacp+9bXP0UKtqG+HTVUIX cg+7k1tLdLz30JQMm9+37R5JtyNrtKVU5DUCiHx4waO89JhXw/8azJCseeAO3hcw1J1M fof/7b5RVWF8JvHNTY7xShg8e8Ej1MUlbBN/nsbZtWMSGltIhgaq21k22wH54MVWzb3t eCo7nlB/f1fEbjz4k94XH28wvAPz8ZlV6W4Fe1+olXkVN6Vttahkk3oovK3Yf50KaKVs sCzJBrs4tzcXNcwXjaHy5b25WbwAmmGa+wlrzvQWfFcl3ermusbGRJWiEfiypLlwYiZH cY6g== X-Gm-Message-State: AC+VfDzljgb5klX1m0Cq9PmOuWcBf8f6w6WtZh/y4iF4REUUNpMEncDs yRsDuo+/FCEVNOJoNSvNczftEnIVOs4= X-Google-Smtp-Source: ACHHUZ6V02e4JVmRpV9vQ/RhjTwrHqh0mFFRU3+k5IXp11/tOwPezCCBpWnEzPbrBEuQO96yuD3cmQ== X-Received: by 2002:a05:6a20:72a8:b0:10c:3cf3:ef7e with SMTP id o40-20020a056a2072a800b0010c3cf3ef7emr2478950pzk.42.1685171241031; Sat, 27 May 2023 00:07:21 -0700 (PDT) Received: from Thaum.localdomain (125-209-144-50.tpgi.com.au. [125.209.144.50]) by smtp.gmail.com with ESMTPSA id 2-20020aa79242000000b006414b2c9efasm3582568pfp.123.2023.05.27.00.07.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 May 2023 00:07:20 -0700 (PDT) Date: Sat, 27 May 2023 17:07:14 +1000 From: Nathaniel Shead To: gcc-patches@gcc.gnu.org Subject: ping: [PATCH] c++: Fix ICE with parameter pack of decltype(auto) [PR103497] Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: 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 > --- > 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 %"); > + 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 >